msp430 lcd display code quotation
The LCD chosen was the: NHD-0216HZ-FSW-FBW-33V3C Character Liquid Crystal Display Module. 2 Lines x 16 Characters and it has a Built?in controller (ST7066U or equivalent)
In the datasheet I saw the 4 bit initialization pseudocode and I am working the project on assembly language on IAR, my question is how can I convert this code to assembly language so I can display something succesfully on the LCD display with the MSP430.
I have found a very simple LCD display "DfRobot LCD for Arduino with rgb backlight". It seems like a good way to have a display with projects but the problem is that for some reason Energia cannot process the code. No matter how I try, i just get an error message: Error compiling for board MSP-EXP430G2ET w/ MSP430G2553. Is there any way to use such displays with Energia?
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.
This is the third tutorial in the sequence of tutorials in which we are learning to program the MSP430G2 LaunchPad using the Energia IDE. In our previous tutorial, we learned how to control the Digital Input and Output pins on our MSP board. In this tutorial, we will learn how to interface an LCD with the board so that we can display useful information.
The LCD that we are using in this project is the most commonly used 16×2 Dot matrix LCD display a.k.an Alphanumeric Displays. Most of us would have come across this either through public PCOs or other electronics projects. A display like this will come in very handy for our future tutorials to display data and other debugging information. Interfacing this LCD with MSP430 is very easy, thanks to the library available. So let’s dive in!!
As told earlier the Energia IDE provides a beautiful library which makes the interfacing a piece of cake and hence it’s not mandatory to know anything about the display module. But, would didn’t it be interesting to show what we are using!!
The name 16×2 implies that the display has 16 Columns and 2 Rows, which together (16*2) forms 32 boxes. One single box would look something like this in the picture below
A single box has 40 pixels (dots) with a matrix order of 5 Rows and 8 columns, these 40 pixels together forms one character. Similarly, 32 characters can be displayed using all the boxes. Now lets take a look at the pinouts.
Out of all these 16 pins, only 10 pins are to be used mandatory for the proper working of the LCD if you want to know more about these LCD display jump to this LCD article.
One major constraint while interfacing these two is their operating voltages. The LCD display has an operating voltage of +5V while the MSP operates only with 3.6V. Lucky for us the data pin of LCD interface IC (HD44780U) has a wide operating voltage of 2.7V to 5.5V. So we have to worry only about the Vdd (pin 2) of the LCD while the data pins can work even with 3.6V.
The MSP430G2 board by default does not give you a +5V pin, but by we can do a smallhack to get +5V from MSP430 using the USB port. If you take a close look near the USB port you can find a terminal called TP1, this terminal will give us +5v. All we have to do is to solder a small male header pin as shown below so that we can connect it to our LCD display.
If you are not interested in soldering simply use any +5V regulated supply and power the LCD, in that case, make sure you connect the ground of your power supply to the ground of the MSP board.
The complete program to interface an MSP430G2553 with LCD display is given at the end of this page. The code can be compiled, uploaded and used as such. In the following paragraphs, I will explain how the program works.
Before we proceed with explanation, we have to make a note of the pins that we are using. If you take a look the circuit diagram above and the MSP430 pin-out diagram below
With this in mind let’s start defining the LCD pins used in our program. We will name each pin with a more meaningful name so that we can use it easily later.
The next step would be to include the LCD library. This library would have been installed automatically when you installed the Energia IDE. So just add it by using the following line
The next step is to mention the pins to which the LCD is connected to, as we have already named it using the #define we can now simply mention the names of the LCD pins. Make sure the same order is followed.
Now let us move into the void setup() function. There are so many types of LCD displays varying in size and nature, the one that we are using is 16*2 so let’s specify that in our program
To print something on the LCD we have to mention two things in the program. One is the position of the text which can be mentioned using the line lcd.setCursor() and other is the content to print which can be mentioned by lcd.print().In this line we are setting the cursor to 1st row and 1st column.
Just like erasing a whiteboard after writing on it, an LCD should also be erased once something is written on it. This can be done by using the below line
Next, inside our void loop() function, let’s keep incrementing a number for every 500ms and display the number in the LCD. This number tests and is initialized to 1 as shown below
Once your hardware and code is ready, simply connect your board the computer and upload the code as we did in tutorial one. Once the code is uploaded you should see the display showing the following.
After two seconds, the display screen will change from setup to loop and start incrementing the variable and display on the screen as shown the below picture.
The complete working can be found in the video below. Go ahead and try changing what’s being displayed on the LCD and play with it. Hope you understood the tutorial and learned something useful form it. If you have any doubts leave them in the comment section below or use the forums. Let’s meet in another tutorial.
This example demonstrates writing to a 20x4 character LCD module based on the HD44780 display controller using the 4-bit parallel interface mode. The example uses a blocking delay to set the update speed of an 8-bit up-counter which is displayed in decimal, hexadecimal, and binary formats on the LCD. This example can be used to explore display characteristics such as refresh rate.
This example requires the MSP430F5529LP development board and a 20x4 character LCD display based on the Hitachi HD44780 LCD Display controller. In order to use the 4-bit parallel interface, it is best to purchase a bare display, such as the Cofufu 20x4 Black on Green LCD module from Amazon. This particular display comes with male and female headers and a 10k potentiometer to implement the contrast adjustment. This will require soldering to connect the headers to the display, and to create the display cable.
The example code provided requires the following connections to be made. For more information on how to make these connections, see the section for building the display cable.
The example code is provided as a main.c file that is available on GitHub at (LCD_Display_4Bit_Counting_Example), or if preferred, it can be cut-pasted from the window below.
After the hardware initialization, the LCD library is initialized, which includes passing it the GPIO pin numbers for RS, RW, EN, D4, D5, D6, and D7. Although the example code was written to use these connections, the code can be modified to use other connections. In that case, the initialization would also need to be modified to identify the GPIO pins used.
The main function consists of a simple "forever loop" that performs a blocking delay of 250 ms, increments the up-counter, and updates the LCD display. This is a very simple program, but it can be useful to investigate the LCD display behavior (such as refresh rate, or "ghosting"), and the behavior of the LCD display library (such as execution time to write a character).
IMPORTANT: It is important to note is that there is an extra initialization step that is performed after the standard initialization function and before entering the forever loop. Updating the LCD display as part of initialization ensures that the display provides a known value to the user on start-up. This ensures that the display does not continue to display old data (or uninitialized data) to the user until the first time it is updated. Without this the display would not be updated until after the first 250 ms delay.
The reason that updating the LCD is done after initialization is that the LCD library uses the TIMERA2 module delay functions and global interrupts must be enabled for them to work properly. As with most things in software programming, there are several ways to do everything. An alternative for this specific example could be to re-arrange the order of operations in the forever loop to update the LCD display first, however I would strongly discourage this approach. This results in the desired behavior, however it makes it less obvious that the intention is to initialize the LCD immediately upon start-up.
If software programming is one of your ambitions, this is an important lesson: always write your code so that it will be obvious to the next person, what it does, and why it does it. Approximately 50% of software errors that result in product recalls are made during software changes after a product is released. Many times this is because some aspect of the code was not obvious to the person making the change.
A better alternative approach would be to add a 4th section to the standard initialization called "program specific initialization that requires interrupts", and move updating the LCD for the first time back into the initialization function. This would make it obvious that updating the LCD is intended to be part of initialization, and that interrupts are required for it to work properly.
The Update_LCD_Display function writes the text to be displayed to the LCD. In this example, the cursor position is set to the beginning of each row, and the text for the entire row is written to the display. Note that even for the first row spaces are included in the quotes after the word "Example" to fill in the rest of the row. This provides a robust solution that re-writes the entire row every time. That way if old data exist, or if noise or a poor connection causes erroneous characters to appear, they are corrected the next time the display updates.
The LCD_Print function works just like the C library function printf. The format string contains embedded format tags, like %3d and %3X, which are replaced by the value specified in s_count_u8 using the formatting specified. %3d reserves 3 spaces to display a decimal number, and %3X reserves 3 spaces to display capitalized hexadecimal values.
The C library doesn"t have functions to display binary values, so the macros BYTETOBINARYPATTERN, and BYTETOBINARY() are used to create the binary format and values. BYTETOBINARYPATTERN is replaced by the format specifier "%d%d%d%d%d%d%d%d", which says to place 8 decimal values one right after the other with no spaces in between. The macro BYTETOBINARY() is passed the count value s_count_u8, and creates a list of 8 comma separated short-hand IF/THEN statements like (byte & 0x80 ? 1 : 0) that says if the eighth bit is non-zero return a 1, else return a 0. For a count value of s_count_u8 = 53 decimal, the string of IF/THEN statements would evaluate to be the string of values: 0,0,1,1,0,1,0,1.
One other thing being done within this LCD Update function is the setting and clearing of the P1.0 LED using the statements P1OUT_bits.P1OUT0 = X, where X = 0 or 1. By asserting the LED during display processing it is possible to use an oscilloscope to measure how long it takes to update the LCD display.
In the example code, the entire display is being updated each time, even though large sections of text like "Decimal:", and "Hexadecimal:" don"t change. This was done intentionally to capture "worst-case" processing times, and to make the example robust so that it recovers if there are connection issues. Processing time can be reduced a little by only updating the values that are changing, but it does reduce the robustness of the design to interference.
In the example, there are 84 commands being sent ot the display for each LCD update: 4 set position commands, and 80 write character commands. The measured time for the entire update process was 11.8 ms, which results in per command processing time of 0.14 ms/command.
Once the example code is built and executed, the end result should be an up-counter that is displayed in decimal, hexadecimal and binary formats, as shown below. (The video snippet only counts from 15 to 28 decimal, but the actual example will count from 0 through 255)
Change the blocking delay value to something very small like delay(1). This will make the display update as fast as possible. Are the digits even readable at this speed?
Before running the example code, the LCD display needs to be connected to the development board. To do this I started with a 20 cm (approx. 8 inch) Female to Female jumper wire ribbon cable and several pieces of 2.5 mm x 30 mm pre-cut heat shrink tubing. I selected 8 different colors to connect to the 4 control and data lines, and then selected 2 sets of the same 2 color combinations to connect to pwr/gnd for the LCD controller and pwr/gnd for the LCD backlight. When the cable was completed it looked like the image below.
The HD44780 LCD Display Controller has a minimum high level input voltage of 2.2V, so all signals output from the MSP430 will be acceptable to the LCD, however when the MSP430 reads from the LCD, the signals on D4-D7 will be driven to 5V, and that is not acceptable, as the MSP430 is not 5V tolerant! Based on measurements that I made on one of my displays, it appears that the HD44780 is limited to driving approx. 1 mA max, which is below the absolute maximum current allowed into the MSP430 protection diodes of 2 mA. This means that if the D4-D7 data lines were connected directly to the MSP430 it would probably be fine. However, it is never a good idea to rely on undocumented features. I added 1 kOhm resistors in series with the four D4-D7 connections. This ensures that the current will always be within a safe level. Any value greater than 1 kOhm would work, but I would recommend staying between 1 kOhm to 2.2 kOhm.
On the V0 signal line I added the 10 kOhm potentiometer that came with the Cofufu display. The potentiometer is a 3-pin device that is intended to be soldered to a PC board. I bent the 3 pins flat, cut the wire for the V0 signal at about 4 inches, and soldered the center-tap pin to the red V0 wire. On the other side of the potentiometer I added two 4 inch wires (white and black) with female receptacles. By connecting the two wires between ground and either the 3V3 or 5V supply, it is possible to adjust the contrast properly.
Not all displays have the pins marked. The pin ordering is as follows when viewed from the front side. It is recommended that this be confirmed using the manufacturer"s datasheet, if one is available.
After soldering the female receptacle (provided with the Cofufu) to the backside of the display, I soldered the wires directly pins on the male header (also provided with the Cofufu). The end result when viewed from the backside of the display is shown below. Keep in mind that the pin names shown above, run in the opposite direction when viewed from the backside. The pin color combinations, running from left to right are: (Pin K - Purple) (Pin A - Blue) (Pin D7 - Grey) (Pin D6 - White) (Pin D5 - Black) (Pin D4 - Brown) (Pin E - Green) (Pin RW - Yellow) (Pin RS - Orange) (Pin V0 - Red) (Pin VDD - Blue) (Pin VSS - Purple).
I connected the backlight anode (Pin A) to the 3V3 supply pin. The LCD backlight connections are intended to be connected to a +5V source (A=+5V, K=GND), however the backlight will function at +3.3V. I think this provides a less harsh and glaring look when using the Yellow/Green displays.
Using the correct bias voltages is essential to get the correct contrast on LCD displays. An incorrect bias voltage could cause the low contrast which you described.
My hypothesis was that this LCD display is really optimised for 5V, and contains a capacitor charge pump (hence the need to add two capacitors) to double the supply voltage in order to generate the required LCD bias voltage, when used with a 3V power supply.
As we see in the datasheet, they use terms "voltage converter" and "voltage booster" for this functionality, although they don"t explain that capacitors are only part of the charge pump; the other charge pump components must be already built into the display"s PCB.
Can you measure the voltage between the VOUT and VSS pins, with a DMM set to measure DC volts? I believe VOUT is the output of a capacitive voltage doubler built-in to the display"s PCB, so I"m hoping for something around 6V on VOUT.
You were right, the VOUT is the output of a capacitive voltage doubler built-in to the display of the PCB, VOUT is around 6V. I measured it and it was only Vcc (around 3V) so I detected that there was a bad connection on my prototype board. I reconnected everything again and it works perfectly.
Aktivmed GlucoCheck Comfort glucose meter- Printed circuit board below the LCD hosting an MSP 430 CPU. https://handwiki.org/wiki/index.php?curid=1894632
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. The device comes in a variety of configurations featuring the usual peripherals: internal oscillator, timer including pulse-width modulation (PWM), watchdog timer (watchdog), USART, Serial Peripheral Interface (SPI) bus, Inter-Integrated Circuit (I²C), 10/12/14/16/24-bit analog-to-digital converters (ADC), and brownout reset circuitry. 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 RS232, 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.[1]
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.[2]
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. 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.
Fixed Function: 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: 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.
Extended Temp: 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. Each port is controlled by the following registers. Ports which do not implement particular features (such as interrupt on state change) do not implement the corresponding registers.
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.[1] The reference cited uses an obscure timer mode to generate high speed strobes for DMA transfers. The timers are not flexible enough to easily make up for the lack of an external DMA transfer strobe.
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.[3] (page 43)
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).[3]
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 Integrated development environment, or IDE. A Kickstart edition can be downloaded for free from TI or IAR; it is limited to 8 KB of C/C++ code in the 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 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.[4]
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.[5] VisSim generated code for a closed loop ADC+PWM based PID control on the F2013 compiles to less than 1 KB flash and 100 bytes RAM.[6] VisSim has on-chip peripheral blocks for the entire MSP430 family I²C, ADC, SD16, PWM.
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. This makes 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 for schools, hobbyists and garage inventors. It is also welcomed by engineers in large companies prototyping projects with capital budget problems.
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.[7] As an addition to experimentation with the LaunchPad a 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 Spy-Bi-Wire by TI. Spy-Bi-Wire was initially introduced on only the smallest devices in the "F2xx family with limited number of I/O pins, such as the MSP430F20xx, MSP430F21x2, and MSP430F22x2. The support for Spy-Bi-Wire has been expanded with the introduction of the latest "5xx family, where all devices have support Spy-Bi-Wire interface in addition to JTAG.
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.
TI introduced a GUI tool to quickly help visual your embedded system. It works inside of the CCS IDE since v5.3. See the offical wiki documentation in order to learn more about the features. This post will be using the MSP430G2553 that comes with the Launchpad to demonstrate the powerful functionality of the GUI builder.
This configures the hardware UART to 9600 baud and utilizes the TX/RX pins. Note You may need to adjust the jumpers on your MSP430 launchpad to connect to the right pins. Look at J3 and orient the two jumpers as shown on the silkscreen.
We won"t be making any modifications to these. You can read a short description here. These files allow the GUI to communicate with your code base. Without it, the GUI will never get updated. You can add as many "live" variables to the GUI without needing to change the monitor.
Create two new files (File->New->Source File / Header File) called uart.c and uart.h. These files are mandatory in order to work with the monitor files as is without modifying them. Inside uart.c paste the following code:
This code forces the received data from the UART module to be sent into the monitor handling function where it will either perform the requested read or write of data.
The main code just delays a bit before incrementing an unsigned 32-bit variable called count. Note how this is a global variable. In order for the GUI Composer to work correctly, all of its binding variables must be global. The delay is 8ms since the default clock is setup to run at 1MHz.
Add a new config file by: File->New->Target Configuration File. Select the MSP430 USB1 as the connection, MSP430G2553 as the device, and then in the "Alternate Communication" box, select "Uart Communication" in the dropdown. Click the "Add" button and you should see a ComPort icon appear.
IF you haven"t already, connect to your MSP430 Launchpad and take note of its enumerated COM port. You can find this information out by using the hardware manager tool inside of windows. If using Linux, you probably already know what you are doing :). Add this and the baud of 9600 as the inputs. Click the "Save" button and exit the window. What you have just done is told CCS to open a line of communication on the UART using the selected COM port at 9600 baud. The GUI Composer tool will utilize this in order to send/receive data from your program.
The Binding inputs will update each widget with its corresponding selected variable name. We have already defined count as a 32-bit variable in our code.
The UARTConnection will be utilized by the GUI Composer to send/receive data. The USB1 connection is used to program and debug your code as usual. Select the UARTConnection instance and then Run->Load->Load Symbols
You probably have the TIMSP430 USB1 instance selected. While the target is running, the debugger prevents memory access. When you halt the target, the debugger allows memory access and the count variable will have incremented. To allow the constant refresh via the USB debugger, goto Tools->Auto Run and Launch Options and deselect the "Halt the target before any debugger access...". You should now see the variable updating in real-time in both USB1 and UART instances.
The refresh rate on default is terribly slow at around 1-2 seconds. Open up a file called app.json located in your workspace. For me, it was located here: H:\ti\workspace\.GUIComposerWS\GUI_Composer_Uart. Append this block of code to see your GUI update much faster:
Once you have your standalone GUI installed, extract the zip file that you just made into your ../guicomposer/webapps folder. Mine is located here: H:\ti\guicomposer\webapps The directory level is critical here. Your files should only be 1 level deep, or else clicking the exe will yield nothing. Connect your MSP430, click on the launcher.exe and your standalone should popup
This book explores the world of microcontroller development through friendly lessons and progressively challenging projects, which will have you blink LEDs, make music with buzzers & interact with different sensors like accelerometers and temperature sensors. This book is focused on the MSP-EXP430G2 LaunchPad Evaluation Kit, which is a complete microcontroller development platform that includes everything you need to start creating microcontroller-based projects. Many of the 25+ projects will also leverage external components, such as the highly-integrated Educational BoosterPack, which is a modular extension to the LaunchPad and includes many components such as an RGB LED, character LCD & potentiometer. This book provides helpful guides that break down hardware circuits through visual diagrams and includes fully-commented code examples. Concepts are broken down and explained in an easy to follow language and analogies to help you understand the principles behind each project/system. The projects will encourage you to use and even combine the fundamental concepts to develop your ideas in creating new microcontroller solutions. Coverage includes: Digital Input/Output: buttons, LEDs, turning anything into a button Analog Input/Output: sensors, temperature, accelerometer, potentiometer, etc. Programming fundamentals: conditional branches & loops, flow, logic, number systems Pulse-Width Modulation (PWM): square wave, buzzer, analog signal simulation Serial Communication: UART, SPI & I2C Code development using Energia, a free, open-source code editor and compiler Debugging through serial communication with a computer Interfacing with external components such as LEDs, buzzers, potentiometers, sensors & more. With the help of this book, you will be challenged to think about developing your own unique microcontroller-based application, and you will be equipped to start solving various problems, adding intelligence to existing products, or even developing your own innovative creations with a LaunchPad development kit.