Sunday, April 15, 2018

msp430 revisit - ccs, gcc

It been a while since my last visit to msp430. MSP430 is a MCU line produced by Texas Instrument. It has low to high end range converge, from msp430g series to msp430f series, now adding msp430fr and msp432 series.

TI CCS IDE is the best ide/compiler that I had been using so far. The GUI is intuitive (it is forked out from eclipse). The TI plugin is stable and features rich. The forum support is fast and intensive. The debugger function is good to use and sturdy.

In addition, the TI launchpad series is cheap and equipped with powerful debugger. However, MSP430 series unable to penetrate the market as well as hobbyist community.

I not so sure about the industry usage, but I am guessing the price. During my previous employment in one of the international home appliance company, I noticed big company has strict control on the price, for every cent they save in a component, it will converts to a big lump sum in mass production. Using cheap MCU is not problem, the company has us (engineer) to solve the problem. This is where the engineer value come in. As engineer, considering same features and equivalent hardware quality, we need to look into the price first before considering other factors like tools, support.

The hobbyist side, Arduino has a good start. So it is hard to catch back. Arduino has huge fan base, large community support, world wide third party vendors. The library support all peripherals and wide range of modules, not to mention the control part. such as PID, CNC milling. The API is dummy and in English language instead of programming language. Not only beginner fond of it, the amateur use it heavily for proof of concept. MSP430 is lacking these types of advantageous.

MSP430 is relatively more complex compared with Microchip PIC18f series. University like to use PIC series for teaching materials, end up the student will use the same MCU after they out of university. Microchip MCU price also relatively cheaper compared with other US MCU manufacturers such as TI, Atmel.

To build up the competency in embedded system, it is good to start with MSP430. It has good support and documentation, you can always google or technical inquires in TI forum. Furthermore, the solidly built debugger ease the learning process as you can always read the register, global variable and putting break point to understand program flow. Arduino is a good start but I always have doubt on the so call "Arduino" expert. Unless you are the one who wrote the Arduino's library, else you are as good as primary school student who is expert in Arduino.

Due to my old PC setup, I am facing some issue when installing CCS8 and CCS7. I end up with CCS6. Still, it is a better version compared with CCS4. Took me quit a while to open CCS6. After it is loaded, CCS6 is functioning smoothly.

I have installed MSP430 GCC through the CCS plugin.
Help->Install New Software->--All Available Sites--->MSP430 GCC Tools->MSP430 GCC Tools (Window)

Manually close the CCS6 again after the MSP430 GCC is installed.

I am using MSP430f5529 launchpad.
Below is my source code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <msp430.h>

int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
  P1DIR |= BIT0;                            // Set P1.0 to output direction
  P1REN |= BIT1;                            // Enable P1.1 internal resistance
  P1OUT |= BIT1;                            // Set P1.1 as pull-Up resistance

  while (1)                                 // Test P1.1
  {
   if (P1IN & BIT1)
    P1OUT &= ~BIT0;                        // if P1.1 clear, set P1.0
   else
    P1OUT |= BIT0;                       // else reset
  }
}

Simply modification from the MSP430f5529 example code.

After compiled, click on the debug button.


It will connect to the on board debugger. It might took a while.

From my example, I am only dealing with port 1 pins. And, I can check the register directly through the view window.

Another convenient feature is changing the register value. You need to stop the program first before you can modify the register value.
For example, I am changing the pin1.0 high/low

The best part on changing pin register is the direct effect observed. The led is turned on and off.

Another good feature breakpoint, (actually all debuggers have this features, but TI one is much better)

And you can activate and deactivate the breakpoint through the GUI, life saver

I not sure how stable is the MSP430 GCC but never argue with free.

I will spent more time reading the MSP430 GCC documentation, in order to fully utilize this compiler.

I am trying to build a freertos demo. Nothing work and I have no idea why.

No comments:

Post a Comment