msp430 lcd display code free sample
This article is the continuation of our tutorial series on programming MSP430 using Code Composer Studio. Last tutorial was based on GPIO pins. This tutorial is about interfacing a display with MSP430, when it comes to display the 16*2 LCD Display,it is the first choice for any electronic hobbyist. Previously we have also interfaced LCD with MSP430 using Arduino IDE, in this tutorial, we will use the native Code Composer studio platform instead of using the Arduino IDE, this way as a designer, we get more flexibility.
It has an in-built IC hd44780 that can store the command and data passed to it. The LCD Module has about 16 pins. 8 of which are data pins, 4 of them are supply pins for backlight LED and the whole LCD module, 3 for controlling the operation, and 1 pin for contrast adjustment. The tutorial is based on the library created by Dennis Eichmann. It is very easy to use a library with separate functions to print different data types. It also has provisions to display the data in different forms with leading, blanked, and deleted zeroes. It is a pretty expansive and comprehensive library and is configurable to the different connections. Here, the header file is modified to accommodate an 8-pin parallel configuration for data communication.
A generic 16x2 Display has an inbuilt hd44780 IC(circled in red below), that can store the command and data passed to it. The LCD Module has about 16 pins. 8 of which are data pins, 4 of them are supply pins for backlight LED and the whole LCD module, 3 for controlling the operation, and 1 pin for contrast adjustment.
This LCD module is shown above versatile and uses minimum pins compared to other segmented LCDs. If you are curious to know how exactly all this works, you should check out the working of the 16x2 LCD display where we have already discussed how the LCD works in detail.
RS Pin: RS=1 will enable the data register in the LCD, which is used to write the values to the data register in LCD. RS=0 will enable the Instruction register of the LCD.
Enable pin: Negative edge-triggered; when the pin is changed from the HIGH state to LOW state, LCD is prompted to write to the data pins. Positive edge-triggered; when the pin is changed from the LOW state to HIGH state, LCD is prompted to read from the data pins.
The tutorial is based on the library created by Dennis Eichmann. It is very easy to use a library with separate functions to print different data types. It also has provisions to display the data in different forms with leading, blanked, and deleted zeroes. It is a pretty expansive and comprehensive library and is configurable to the different connections. Here, the header file is modified to accommodate an 8-pin parallel configuration for data communication. The library can be download from the below link, after downloading you follow the below steps to add the library to CCS.
In the properties dialog box of the hd44780 project and inside the include options for the MSP430 compiler, add the include folder in file the search path.
In the properties dialog box for the CCS_LCD project and in the file search path of MSP430 Linker tab, include the hd44780.lib located inside the debug folder of the hd44780 project. The debug folder is also included in the file search path.
void hd44780_timer_isr( void ):This is periodically called in the ISR of the Timer A. The Timer A is used to periodically do the LCD functions like clearing the screen, setting the cursor, and displaying the data. The function is to be used in the ISR. It returns nothing.
char * ch__string:The string to be written to the data buffer (inside the hd44780_timer_isrfunction). The data will be copied to the data register and instruction register of the LCD IC when the hd44780_timer_isris periodically called.
uint8_t hd44780_output_unsigned_16bit_value( uint16_t u16__value, uint8_t u8__leading_zero_handling, uint8_t u8__row, uint8_t u8__column, uint8_t u8__cr_lf ):The function will display the unsigned 16-bit value on the desired location of the LCD.
The anode of the LED backlight cannot be connected directly to a 5V supply. It should be connected to a resistance to minimize the current flow through the LCD Module. I have made my connections using a perf board to solder the LCD and then used jumper wires to connect the LCD with the MSP430 board, my set-up looks like this below but you can also simply use a breadboard to make your connections.
The complete code used in this project is given at the bottom of this page. The explanation of using the code is as follows. First, open the header file (hd44780.h) and include the microcontroller part number in the first part of the file.
Inbuilt timer is being used to display values periodically. Timer A is selected with SMCLK (1MHZ) as the clock source and continuous mode being the mode of operation.
Once you have your code compiled, you can upload it to the MSP430 board, as explained in the getting started with the MSP430 tutorial. If everything goes as expected, you should see your LCD display some contrast as shown below.
Lcd16x2Now there is a protruding rectangular portion on this LCD. This will help you identify which pin is which. Now let us see what each pin does exactly. But then they have also printed 16 and 1 on the back of LCD, so no need to worry about connecting the pins inverted.
So basically when you vary the pot , you get different values of voltage from the voltage divider network. And thus you can change the contrast to suit your visual needs. (Caution: Do not give the LCD voltage greater than 5 Volts. Your LCD may get damaged. By more I"m not talking about 5.1 Volts but 6 V and beyond.)
RS : This stands for register select. The two registers in LCD are the data register and the command word/code register. In order to tell LCD that the bits on databus are for which register we make use of RS control signal via the RS pin. When you make this pin high you select data register, where you"ll send the ASCII values to be displayed on screen. When you make RS low you select the command word register where you"ll be sending all the commands for configuring and initializing the LCD.
R/W : This stands for read or write. The read is active high signal and write is active low. Thus when you want to read from the LCD you make the signal on this pin high and when you want to write you make the signal on this pin low.
E : This stands for enable. This is a edge triggering signal which is used while writing or reading data to/from LCD respectively. E line is negative edge triggered for write while it is positive edge triggered for the read. The timing diagram given in datasheet tells about the minimum delay between the level transitions.
Busy Flag : The concept of busy flag is beautiful. Now the LCD internal processor takes time to latch and make the necessary adjustments as per the command word. While the LCD"s internal processor is busy this flag is set. So one should check the status of this flag before sending the next command word or data. D7 is the busy flag pin. You"ll have to configure the port pin connected to D7 pin as input while checking the flag condition. Along with this we need to make RS = 0 and R/W = 1 , since this is read operation and busy flag is given by command code register mode.
Well you can give delays also for LCD to finish work, but this is better way if you have enough port pins. Because for reading busy flag status you need R/W signal and thus a port pin.
Using the above table you can make any command byte. For example we"ll be using this LCD in 8 bit mode so make DL = 1, N = 1 and F =0 respectively. The hexadecimal value that we get is 0x38/038h. This is the command word that we must send to the LCD to initialize it in 8 bit mode and use 2 lines with 5x7 dots.
So these are few of the instruction codes that you come across frequently. Of course you can make these on your own by using the command code syntax table.
Display data random access memory. This is where the data you send to data register is stored. And it so happens that you can send the address of block to the command code register to position the cursor at that particular block. For example you want to position the cursor at row 2 column 10 , just send 0CAh to the command code register. So that is about the DDRAM and positioning the cursor.
In this MSP430 ADC tutorial the MSP430G2253 will be used as an example. Texas Instruments ships the MSP430G2253 microprocessor with the latest Launchpad, the datasheet for the MSP430G2253 can be downloaded here
The MSP430G series devices are supplied in a number of packages with different specification and peripherals, there are 2 types of ADC, ADC10 and ADC12. The ADC10 is a 10bit analog to digital conversion and the ADC12 is a 12bit analog to digital conversion. The MSP430G2253 only incorporates the ADC10, apart from having greater resolution the ADC12 does not differ that much from the ADC10. Suggested reading on the main differences between the 2 types of ADC is the MSP430x2xx Family User’s Guide, which at the time of writing is release SLAU144J here
Before reading further if you are having trouble understanding how the registers work, and how the C code updates the individual register settings? It would be worth reading my MSP430 Programming Tutorial, Part 1 covers the basics and Part 2 gives clear examples. You can find them here Part 1 and Part 2.
So now we understand the term regarding bit size, we need to find the range. The range is defined as what voltage range the ADC accepts, to find this we need to consult the datasheet for the MSP430G2253, an extracted image from the datasheet can be seen below.
Now the value of 512 or 2048 is the value that would be stored as a variable by the ADC, this can actually be seen in Code Composer Studio and will be demonstrated later on in this tutorial.
The ADC10 module on the MSP430G devices is configured by the user through software. There are various registers used to change the way the ADC10 operates dependent on the application requirements.
Control register 0 has various parameters that can be set which are listed below, the MSP430 Family Guide SLAU144J has a full list of all these parameters with more in depth descriptions. The command used for this register looks something like this ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE;
Control register 1 has various parameters that can be set which are listed below, the MSP430 Family Guide SLAU144J has a full list of all these parameters with more in depth descriptions. The command used for this register looks something like this ADC10CTL1 = INCH_10 + ADC10DIV_3 + CONSEQ_2;
The code pasted below will perform a repeated read from GPIO P1.0 and then using the DTC, it will copy the value into an array. The DTC automatically increments the address of the array. The integer array containing the value is then added together and divided by 10 to give an average value, which is assigned to the variable avg_adc.
The image below shows a screen capture from the debug mode in code composer studio. By using a breakpoint and watching the expressions adc[10] and avg_adc, the values can be viewed changing (almost live) as the input to the ADC changes. A light dependent resistor circuit was used as input to the ADC in this case.
The 3rd example reads 3 separate GPIO pins repeatedly, these pins are p1.1, p1.2 and p1.3. The program was originally written to be used with an analog 3 axis accelerometer, so some of the variables are still named in this manner. Most of the comments within the code have been removed to reduce the size of the snippet, however the fully commented code can be downloaded below.
Port 2 can be used to provide the six data signals required to control the LCD. Note how the LCD is connected to the breadboard and that wires can be connected to the pins as shown in figure 1. There is a four bit interface for the data (D4-D7), a RS (select command versus text) and an enable (E). Figure 2 shows the other required connections as well. The datasheet for the LCD can be found here GDM1602K-Extended.pdf. The commands are correct but the electrical specifications may vary between LCDs so make sure you have the correct datasheet for your specific LCD (3.3V versus 5.0V for instance)
Specific to this lab and the corresponding lcd_lib files we will setup the LCD to use all six available pins in Port 2 to write directly to the 16 x 2 LCD in 4-bit operation using only the most significant data nibble.
Show the TA your code, functional board and answer questions posed. 20% credit for functional code and 80% credit for correct answers about the code. You will be expected to explain every line of code for full credit.
Photo of two experimenter boards for the MSP430 chipset by Texas Instruments. On the left the larger chip version, on the right a small version in USB format.
The MSP430 is a mixed-signal microcontroller family from Texas Instruments, first introduced on 14 February 1992.CPU, the MSP430 is designed for low cost and, specifically, low power consumption
The MSP430 can be used for low powered embedded devices. The current drawn in idle mode can be less than 1 µA. The top CPU speed is 25 MHz. It can be throttled back for lower power consumption. The MSP430 also uses six different low-power modes, which can disable unneeded clocks and CPU. Further, the MSP430 can wake-up in times under 1 microsecond, allowing the controller to stay in sleep mode longer, minimizing average current use.
Some less usual peripheral options include comparators (that can be used with the timers to do simple ADC), on-chip operational amplifiers (op-amp) for signal conditioning, 12-bit digital-to-analog converter (DAC), liquid crystal display (LCD) driver, hardware multiplier, USB, and direct memory access (DMA) for ADC results. Apart from some older erasable programmable read-only memory (EPROM, such as MSP430E3xx) and high volume mask ROM (MSP430Cxxx) versions, all of the devices are in-system programming enabled via Joint Test Action Group (JTAG), full four-wire or Spy-Bi-Wire), a built in bootstrapping loader (BSL) using UART such as RS-232, or USB on devices with USB support. No BSL is included in F20xx, G2xx0, G2xx1, G2xx2, or I20xx family devices.
There are, however, limits that preclude its use in more complex embedded systems. The MSP430 does not have an external memory bus, so it is limited to on-chip memory, up to 512 KB flash memory and 66 KB random-access memory (RAM), which may be too small for applications needing large buffers or data tables. Also, although it has a DMA controller, it is very difficult to use it to move data off the chip due to a lack of a DMA output strobe.
Six general generations of MSP430 processors exist. In order of development, they are: "3xx generation, "1xx generation, "4xx generation, "2xx generation, "5xx generation, and "6xx generation. The digit after the generation identifies the model (generally higher model numbers are larger and more capable), the third digit identifies the amount of memory included, and the fourth, if present, identifies a minor model variant. The most common variation is a different on-chip analog-to-digital converter.
The MSP430x1xx Series is the basic generation without an embedded LCD controller. They are generally smaller than the "3xx generation. These flash- or ROM-based ultra-low-power MCUs offer 8 MIPS, 1.8–3.6 V operation, up to 60 KB flash, and a wide range of analog and digital peripherals.
The MSP430F2xx Series are similar to the "1xx generation, but operate at even lower power, support up to 16 MHz operation, and have a more accurate (±2%) on-chip clock that makes it easier to operate without an external crystal. These flash-based ultra-low power devices offer 1.8–3.6 V operation. Includes the very-low power oscillator (VLO), internal pull-up/pull-down resistors, and low-pin count options.
The MSP430G2xx Value Series features flash-based Ultra-Low Power MCUs up to 16 MIPS with 1.8–3.6 V operation. Includes the Very-Low power Oscillator (VLO), internal pull-up/pull-down resistors, and low-pin count options, at lower prices than the MSP430F2xx series.
The MSP430x3xx Series is the oldest generation, designed for portable instrumentation with an embedded LCD controller. This also includes a frequency-locked loop oscillator that can automatically synchronize to a low-speed (32 kHz) crystal. This generation does not support EEPROM memory, only mask ROM and UV-eraseable and one-time programmable EPROM. Later generations provide only flash memory and mask ROM options. These devices offer 2.5–5.5 V operation, up to 32 KB ROM.
The MSP430x4xx Series are similar to the "3xx generation, but include an integrated LCD controller, and are larger and more capable. These flash or ROM based devices offers 8–16 MIPS at 1.8–3.6 V operation, with FLL, and SVS. Ideal for low power metering and medical applications.
Other integrated peripherals: SCAN_IF, ESP430, 12-bit DAC, Op Amps, RTC, up to 2 16-bit timers, watchdog timer, basic timer, brown-out reset, SVS, USART module (UART, SPI), USCI module, LCD Controller, DMA, 16×16 & 32x32 multiplier, Comparator_A, temperature sensor, 8 MIPS CPU Speed
The MSP430x5xx Series are able to run up to 25 MHz, have up to 512 KB flash memory and up to 66 KB RAM. This flash-based family features low active power consumption with up to 25 MIPS at 1.8–3.6 V operation (165 uA/MIPS). Includes an innovative power management module for optimal power consumption and integrated USB.
The MSP430x6xx Series are able to run up to 25 MHz, have up to 512 KB flash memory and up to 66 KB RAM. This flash-based family features low active power consumption with up to 25 MIPS at 1.8–3.6 V operation (165 uA/MIPS). Includes an innovative power management module for optimal power consumption and integrated USB.
Other integrated peripherals: USB, LCD, DAC, Comparator_B, DMA, 32x32 multiplier, power management module (BOR, SVS, SVM, LDO), watchdog timer, RTC, Temp sensor
Other integrated peripherals: LCD Controller, up to 2 16-bit timers, watchdog timer, RTC, power management module (BOR, SVS, SVM, LDO), USCI module, DMA, 32x32 multiplier, Comp B, temperature sensor
Other possible integrated peripherals: MPU, up to 6 16-bit timers, watchdog timer, RTC, power management module (BOR, SVS, SVM, LDO), USCI module, DMA, multiplier, Comp B, temperature sensor, LCD driver, I2C and UART BSL, Extended Scan Interface, 32 bit multiplier, AES, CRC, signal processing acceleration, capacitive touch, IR modulation
The Low Voltage Series include the MSP430C09x and MSP430L092 parts, capable of running at 0.9 V. These 2 series of low voltage 16-bit microcontrollers have configurations with two 16-bit timers, an 8-bit analog-to-digital (A/D) converter, an 8-bit digital-to-analog (D/A) converter, and up to 11 I/O pins.
The MSP430BQ1010 16-bit microcontroller is an advanced fixed-function device that forms the control and communications unit on the receiver side for wireless power transfer in portable applications. MSP430BQ1010 complies with the Wireless Power Consortium (WPC) specification. For more information, see Contactless Power
Automotive MSP430 microcontrollers (MCUs) from Texas Instruments (TI) are 16-bit, RISC-based, mixed-signal processors that are AEC-Q100 qualified and suitable for automotive applications in environments up to 105 °C ambient temperature. LIN compliant drivers for the MSP430 MCU provided by IHR GmbH.
MSP430 devices are very popular in harsh environments such as industrial sensing for their low power consumption and innovative analog integration. Some harsh environment applications include transportation/automotive, renewable energy, military/space/avionics, mineral exploration, industrial, and safety & security.
Note that when the flash size is over 64K words (128 KBytes), instruction addresses can no longer be encoded in just two bytes. This change in pointer size causes some incompatibilities with previous parts.
The MSP430 peripherals are generally easy to use, with (mostly) consistent addresses between models, and no write-only registers (except for the hardware multiplier).
The MSP430 family defines 11 I/O ports, P0 through P10, although no chip implements more than 10 of them. P0 is only implemented on the "3xx family. P7 through P10 are only implemented on the largest members (and highest pin count versions) of the "4xx and "2xx families. The newest "5xx and "6xx families has P1 through P11, and the control registers are reassigned to provide more port pairs.
Port x interrupt vector ("5xx only). This 16-bit register is a priority encoder which can be used to handle pin-change interrupts. If n is the lowest-numbered interrupt bit which is pending in PxIFG and enabled in PxIE, this register reads as 2n+2. If there is no such bit, it reads as 0. The scale factor of 2 allows direct use as an offset into a branch table. Reading this register also clears the reported PxIFG flag.
The MSP430 line offers two types of analog-to-digital conversion (ADC). 10- and 12-bit successive approximation converters, as well as a 16-bit Sigma-Delta converter. Data transfer controllers and a 16-word conversion-and-control buffer allow the MSP430 to convert and store samples without CPU intervention, minimizing power consumption.
The MSP430"s comparator module provides precision slope analog-to-digital conversions. Monitors external analog signals and provides voltage and resistor value measurement. Capable of selectable power modes.
The BOR circuit detects low supply voltages and resets the device by triggering a power-on reset (POR) signal when power is applied or removed. The MSP430 MCU’s zero-power BOR circuit is continuously turned on, including in all low-power modes.
Although the MSP430"s DMA subsystem is very capable it has several flaws, the most significant of which is the lack of an external transfer strobe. Although a DMA transfer can be triggered externally, there is no external indication of completion of a transfer. Consequently DMA to and from external sources is limited to external trigger per byte transfers, rather than full blocks automatically via DMA. This can lead to significant complexity (as in requiring extensive hand tweaking of code) when implementing processor to processor or processor to USB communications.
The EEM provides different levels of debug features such as 2-8 hardware breakpoints, complex breakpoints, break when read/write occurs at specified address, and more. Embedded into all flash-based MSP430 devices.
Some MSP430 models include a memory-mapped hardware multiplier peripheral which performs various 16×16+32→33-bit multiply-accumulate operations. Unusually for the MSP430, this peripheral does include an implicit 2-bit write-only register, which makes it effectively impossible to context switch. This peripheral does not interfere with CPU activities and can be accessed by the DMA. The MPY on all MSP430F5xx and some MSP430F4xx devices feature up to 32-bit x 32-bit.
The FRAM MPU protects against accidental writes to designated read-only memory segments or execution of code from a constant memory. The MPU can set any portioning of memory with bit level addressing, making the complete memory accessible for read, write and execute operations in FRAM devices.
MSP430 devices have up to 12 digital I/O ports implemented. Each port has eight I/O pins. Every I/O pin can be configured as either input or output, and can be individually read or written to. Ports P1 and P2 have interrupt capability. MSP430F2xx, F5xx and some F4xx devices feature built-in, individually configurable pull-up or pull-down resistors.
The universal synchronous/asychrnous receive/transmit (USART) peripheral interface supports asynchronous RS-232 and synchronous SPI communication with one hardware module. The MSP430F15x/16x USART modules also support I²C, programmable baud rate, and independent interrupt capability for receive and transmit.
Available on the MSP430FR4xxx and MSP430FR2xxx series chips, this feature is configured via the SYSCFG register set. This peripheral ties into other peripherals (Timers, eUSCI_A) to generate an IR modulated signal on an output pin.
The LCD/LCD_A controller directly drives LCDs for up to 196 segments. Supports static, 2-mux, 3-mux, and 4-mux LCDs. LCD_A module has integrated charge pump for contrast control. LCD_B enables blinking of individual segments with separate blinking memory.
The LCD_E controller comes with the newer MSP430FR4xxx series microcontrollers and directly drives LCDs up to 448 segments. Supports static, 2-mux, 3-mux, 4-mux, 5-mux, 6-mux, 7-mux, 8-mux (1/3 bias) LCDs. Segment and Common pins may be reprogrammed to available LCD drive pins. This peripheral may be driven in LPM3.5 (RTC running+Main CPU core shutdown low-power mode).
Texas Instruments provides various hardware experimenter boards that support large (approximately two centimeters square) and small (approximately one millimeter square) MSP430 chips. TI also provides software development tools, both directly, and in conjunction with partners (see the full list of compilers, assemblers, and IDEs). One such toolchain is the IAR C/C++ compiler and debugger (assembly language programs of any size can be developed and debugged with this free toolchain).
TI also combines a version of its own compiler and tools with its Eclipse-based Code Composer Studio IDE (CCS). It sells full-featured versions, and offers a free version for download which has a code size limit of 16 KB. CCS supports in-circuit emulators, and includes a simulator and other tools; it can also work with other processors sold by TI.
For those who are more comfortable with the Arduino, there is also another software Energia, an open source electronics prototyping platform with the goal to bring the Wiring and Arduino framework to the Texas Instruments MSP430 based LaunchPad where Arduino code can be exported for programming MSP430 chips. The latest release of Energia supports the MSP-EXP430G2xxx, MSP-EXP430FR5739, MSP-EXP430FR5969, MSP-EXP430FR5994, MSP-EXP430F5529LP, Stellaris EK-LM4F120XL, Tiva-C EK-TM4C123GXL, Tiva-C EK-TM4C1294XL, CC3200 WiFi LaunchPad.
TI consulted with RedHat to provide official support for the MSP430 architecture to the GNU Compiler Collection C/C++ compiler. This msp430-elf-gcc compiler is supported by TI"s Code Composer Studio version 6.0 and higher.
Other commercial development tool sets, which include editor, compiler, linker, assembler, debugger and in some cases code wizards, are available. VisSim, a block diagram language for model based development, generates efficient fixed point C-Code directly from the diagram.closed loop ADC+PWM based PID control on the F2013 compiles to less than 1 KB flash and 100 bytes RAM.
The MSP430F2013 and its siblings are set apart by the fact that (except for the MSP430G2 Value Line) it is the only MSP430 part that is available in a dual in-line package (DIP). Other variants in this family are only available in various surface-mount packages. TI has gone to some trouble to support the eZ430 development platform by making the raw chips easy for hobbyists to use in prototypes.
TI has tackled the low-budget problem by offering a very small experimenter board, the eZ430-F2013, on a USB stick (now obsolete). This made it easy for designers to choose the MSP430 chip for inexpensive development platforms that can be used with a computer. The eZ430-F2013 contains an MSP430F2013 microcontroller on a detachable prototyping board, and accompanying CD with development software. It is helpful
Texas Instruments released the MSP430 LaunchPad in July 2010. The MSP430 LaunchPad has an onboard flash emulator, USB, 2 programmable LEDs, and 1 programmable push button.shield board is available.
All three of these LaunchPads include an eZ-FET JTAG debugger with backchannel UART capable of 1Mbit/s speeds. The FRAM LaunchPads (e.g. MSP-EXP430FR5969, MSP-EXP430FR4133) include EnergyTrace, a feature supported by TI"s Code Composer Studio IDE for monitoring and analyzing power consumption.
In common with other microcontroller vendors, TI has developed a two-wire debugging interface found on some of their MSP430 parts that can replace the larger JTAG interface. The eZ430 Development Tool contains a full USB-connected flash emulation tool (FET) for this new two-wire protocol, named
The advantage of the Spy-Bi-Wire protocol is that it uses only two communication lines, one of which is the dedicated _RESET line. The JTAG interface on the lower pin count MSP430 parts is multiplexed with general purpose I/O lines. This makes it relatively difficult to debug circuits built around the small, low-I/O-budget chips, since the full 4-pin JTAG hardware will conflict with anything else connected to those I/O lines. This problem is alleviated with the Spy-Bi-Wire-capable chips, which are still compatible with the normal JTAG interface for backwards compatibility with the old development tools.
JTAG debugging and flash programming tools based on OpenOCD and widely used in the ARM architecture community are not available for the MSP430. Programming tools specially designed for the MSP430 are marginally less expensive than JTAG interfaces that use OpenOCD. However, should it be discovered mid-project that more MIPS, more memory, and more I/O peripherals are needed, those tools will not transfer to a processor from another vendor.
The MSP430 CPU uses a von Neumann architecture, with a single address space for instructions and data. Memory is byte-addressed, and pairs of bytes are combined little-endian to make 16-bit words.
The MSP430X extension with 20-bit addressing adds added instructions that can require up to 10 clock cycles. Setting or clearing a peripheral bit takes two clocks. A jump, taken or not takes two clocks. With the 2xx series 2 MCLKs is 125 ns at 16 MHz.
The basic MSP430 cannot support more memory (ROM + RAM + peripherals) than its 64K address space. In order to support this, an extended form of the MSP430 uses 20-bit registers and a 20-bit address space, allowing up to 1 MB of memory. This uses the same instruction set as the basic form, but with two extensions:
If the instruction is register-to-register, a different extension word is used. This includes a "ZC" flag which suppresses carry-in (useful for instructions like DADD which always use the carry bit), and a repeat count. A 4-bit field in the extension word encodes either a repeat count (0–15 repetitions in addition to the initial execution), or a register number which contains a 4-bit repeat count.
There is a new extended version of the architecture (named MSP430X) which allows a 20-bit address space. It allows added program ROM beginning at 0x10000.
The size bit is named A/L, where L (long) is used by other processors to indicate 32-bit operands. Also the description of the SXTX instruction (MSP430F5xx Family User"s Guide alau208f page 237) describes the effect of the instruction in register bits 20–31.
I"m using an MSP430 MCU to read analog signals and display the results on an LCD with a SPI connection. The LCD is a 16x2 that is connected according to the SPI connection details on the Datasheet and uses a Hitachi HD44780 driver. I can fill up the 16 characters of the first row no problem. When I go over 16, the last character does not display(as expected) even if I extend the char array that holds the string that I want to print. The problem is that the second row never displays anything. When there are no characters in a position in the first row, there is still a faint background in all positions, but the second row is always continuously blank. Below are the functions that are used in printing. What am I doing wrong?
I know the wiring is correct and the LCD is functional. To test these, I wired the display to an arduino to test, since the code is much easier and I was able to display characters in bow rows. The non-descriptive variables are defined by the MSP430 source files and include registers, buffers, and other controls to put the device in SPI communication mode.
We are going to discuss about the liquid crystal display which is liquid crystal display. what is the purpose of general displays? and how many types are available in the market. Based on what our people are going to choose this lcd devices in our electronics applications. Before you learn this device interfacing with MSP430G2 launchPad, you need to understand the pinout of 16×2 LCD. For details about the 16×2 check this article:
So to display 16 character in one line, we need to control 5 x 8 x 16 grids or dot. But fortunately, this liquid display has build in controller which take care of all these grids control and it provide us pin out to send text and control the display. So we do not need to worry about controlling these light grids to display characters. 16×2 LCD which has on board HD44780U controller which provides us pin out as shown in figure above. Now lets talk about pin out and how to interface it with MSP430 microcontroller. Picture below shows the description of each pin.
Now I will talk about how to interface 16×2 LCD with MSP430 microcontroller. It requires 5 volts dc supply to operate and current consumption is approximately 10 milliamps current 16 cross 2 lcd. It has total 16 pins so the 16 pins you have to control.
So these are complete 16 pins oflcd screen. First pin and second pin feature for power supply of the device. So with the help of these 2 pins only you are going to provide the power supply. Coming to third pin which is contrast and this contrast pin can connect with thehelp of one variable resistor. Variable resistor having three pins generally the first pin is vcc and another pin is ground. Third variable pin you are going to connect with your third pin of the device . By varying the resistance for variable resistor is going to increase or decrease the brightness of screen. Pin number four five six these are the three control lines of lcd device. Description of other pins is given above.
you will learn how to interface LCD with MSP430G2 LanuchPad. Now you are already now about pinouts 16X2 LCD. Now lets see how to connect it with MSP430G2 launchPad. This module has 8 data pins from D0-D7 which will be used to send data from MSP430G2 GPIO pins to LCD. But we have a option to use LCD either in 4 bit mode or 8 bit mode. In 8 bit mode we need to use 8 GPIO pins of MSP430 and in 4 bit mode we need to use only 4 GPIO pins to connect with data pins of display. So it is always better to use it in 4 bit mode, because we can save GPIO pins of MSP430 for other purpose. We need other purpose pins of MSP430 also to connect with RS pin and Enable pin of LCD module. Always connect R/W pin to ground because we only want to write data only LCD
Note: one issue while interfacing it with MSP430 microcontroller is that MSP430 microcontroller operate on 3.3 volt and LCD operates on 5 volt. So we need a separate power supply to power this device. But fortunately, MSP430G2 lanuchPad has on board connector for 5 volt with the name of TP1, you can solder a connector to this pin and get 5 volt from there. Data pins of Liquid crystal display has wide operating voltage range from 3 -5 volt. So there will be no issue with them.
So in this example you have learnt how to display text on two lines and how to set cursor values. So now lets see another example to display integer or counter values on liquid crystal display.
In this example, I will use the same circuit diagram as we used in last example. But we change the code little bit. In this example, a counter value will be increment every one second and its value will be displayed on screen after every one second. Connection of 16×2 is same with MSP430 microcontroller as it were shown in last example of this article. Code is given below:
I have done certain calculations for calculating rpm in the main code and now i want the values to be printed on the LCD but here i am not able to understand how to do it.
The code of lcd which i have used takes only *char as input , so i am not able to find out a way to convert the integer to char(I know it sounds lame but ...stilll.....) and print it on lcd.
[JB’s] driving a Nokia 6100 LCD using an MSP430 with input from a Wii Nunchuck. He’s using the G2211 microprocessor that came with the Launchpad, and developing his code with MSP-GCC. As you can see in the video after the break, this works but there’s some room for improvement. That’s being said, he is bumping up against the code memory limit, with just around 500 bytes left to work with. The LCD screen is SPI and currently it’s hogging the pins that are used for the hardware i2c. Since he needs an i2c bus to talk to the nunchuck he had to go with software i2c which explains part of his program memory troubles.
We’re in no way experts on this, but it seems like he could save space (and improve the input responsiveness) by rewriting his LCD drivers in order to remap the pins. Then again, it might just be better to move up to a larger MSP430. If you’ve got some advice, make sure to share it by leaving a comment.