Introduction

This is my first look at the Texas Instruments MSP430FR2000 microcontroller.  It got my attention because of this recent post at Texas Instruments:  http://newscenter.ti.com/2017-11-08-Texas-Instruments-offers-25-functions-for-25-cents-with-new-MSP430-TM-microcontrollers

Twenty five functions for 25 cents sounds pretty good but be aware that if you are a hobbyist buying in small quantities you won’t be able to get these MCUs for anywhere near 25 cents.  However, they are reasonably priced and well worth having a look at the free e-book in the link above. 

I don’t have a project in mind for the FR2000 but the concept of adding inexpensive microcontrollers to something like the Raspberry Pi is interesting.  For example, it could be used to expand GPIO or add ADC capability.  It could also be used to add real time response when needed.  The FRAM nonvolatile memory also has interesting possibilities. 

In this blog post I will show how I hooked a MSP430FR2000 up for use on a breadboard and my give first impressions.

Getting Started

It comes in 16 pin TSSOP or 24 pin VQFN versions.  I chose the TSSOP because I am able to hand solder those without too much difficulty.   Here is the seemingly obligatory photo of the device next to a coin:

Here is the pinout:

 

The FR2111 is the same package and pin compatible.  The difference is memory and of course cost:

DeviceProgram FRAM (Kbytes)SRAM (Bytes)Small Qty Cost (US$)
MSP430FR21113.751024$1.16
MSP430FR20000.5512$0.85

 

I had a 28 pin TSSOP adapter on hand and soldered the FR2000 to it.  The connections to program it are simple and clearly described in the datasheet.  I used a 1 uF capacitor to ground for DVCC and a 1 nF capacitor to ground for RST.  It is also necessary to put a 47 k ohm pull-up resistor on RST.  Here it is on a breadboard ready to be programmed:

 

I program using with a TI LauchPad – just hook GND, 3V3, RST, and TST to their equivalents on the emulator side of the LaunchPad and you are ready to go.  This is one of the things I like about the MSP430 – really cheap and easy to get going.

 

Programming

I used Texas Instruments Code Composer Studio to program and the free TI v17.9.0.STS compiler.  I am a self-taught amateur programmer and with this little memory can use all the help I can get.  The code memory model and the data memory model were set to small in the Compile Processor Options.  The Optimization level was set to optimize size.  By the way, the e-book in the link above has helpful hints on minimizing code size as well as porting to larger MSP430 MCUs if needed.

It wouldn’t be right to start off with a simple blink program, so here is a simple counter that displays in binary on LEDs instead.

 

And here is the code:

 

/*
 *  MSP430FR2000 Binary Counter Display
 *
 *  Description: counts to 255 and displays on LEDs on Port 1
 *  ACLK = n/a, MCLK = SMCLK = default DCO
 *
 *                MSP430FR2000
 *             -----------------
 *         /|\|             P1.0|-->LED
 *          | |             P1.1|-->LED
 *          --|RST          P1.2|-->LED
 *            |             P1.3|-->LED
 *            |             P1.4|-->LED
 *            |             P1.5|-->LED
 *            |             P1.6|-->LED
 *            |             P1.7|-->LED
 *
 *  Frank Milburn
 *  November 2017
 */

#include 

void main(void) {
    WDTCTL = WDTPW | WDTHOLD;               // Stop watchdog timer
    PM5CTL0 &= ~LOCKLPM5;                   // Disable the GPIO power-on default high-impedance mode
                                            // to activate previously configured port settings
    P1OUT &= 0x00;                          // Set port 1 off
    P1DIR |= 0xFF;                          // Set port 1 to output direction

    for(;;) {
        int i;
        for (i = 0; i < 256; i++){
            int temp;
            temp = 0x00;                    // Zero temporary variable
            temp |= i;                      // Set bits to display
            P1OUT = temp;                   // Display bits
            volatile unsigned int j;        // volatile to prevent optimization
            j = 2500;                       // SW Delay
            do j--;
            while(j != 0);
        }
    }
}

 

The code compiles and reports the following memory usage:  FRAM 132 bytes and RAM 160 bytes.

If you are accustomed to writing directly to registers then the comments will make it pretty clear what is going on.  Recently I have been avoiding this style though as I find it difficult to debug when I go back after a period of time.  I don’t do enough programming to remember what register is what.  Instead, I tend to use DriverLib when I can.

TI describes DriverLIb as an abstracted API that provides easy to use function calls with helpful documentation to write complete projects with minimal overhead.  In use it involves more typing but I can live with that.  I wondered how much if any overhead there would be to this simple example so here it is rewritten using the DriverLib API to set up the pins the way I might normally do it (output for binary display remains the same).

/*
 *  MSP430FR2000 Binary Counter Display using DriverLib to set up pins
 *
 *  Description: counts to 255 and displays on LEDs on Port 1
 *  ACLK = n/a, MCLK = SMCLK = default DCO
 *
 *                MSP430FR2000
 *             -----------------
 *         /|\|             P1.0|-->LED
 *          | |             P1.1|-->LED
 *          --|RST          P1.2|-->LED
 *            |             P1.3|-->LED
 *            |             P1.4|-->LED
 *            |             P1.5|-->LED
 *            |             P1.6|-->LED
 *            |             P1.7|-->LED
 *
 *  Frank Milburn
 *  November 2017
 */
#include "driverlib.h"

int main(void) {

    WDT_A_hold(WDT_A_BASE);

    PMM_unlockLPM5();

    GPIO_setOutputLowOnPin(
        GPIO_PORT_PA,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 + GPIO_PIN3 +
        GPIO_PIN4 + GPIO_PIN5 + GPIO_PIN6 + GPIO_PIN7
        );

    GPIO_setAsOutputPin(
        GPIO_PORT_PA,
        GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 + GPIO_PIN3 +
        GPIO_PIN4 + GPIO_PIN5 + GPIO_PIN6 + GPIO_PIN7
        );

    for(;;) {
        int i;
        for (i = 0; i < 256; i++){
            int temp;
            temp = 0x00;                    // Zero temporary variable
            temp |= i;                      // Set bits to display
            P1OUT = temp;                   // Display bits
            volatile unsigned int j;        // volatile to prevent optimization
            j = 2500;                       // SW Delay
            do j--;
            while(j != 0);
        }
    }
}

 

The program now compiles to FRAM: 282 bytes and RAM: 160 bytes.

RAM remains the same but program memory in FRAM has increased by 150 bytes and only 218 bytes remain.  The good news is that DriverLib is available (it isn’t on the MSP430G series) but for this particular chip tighter coding is needed and I wouldn’t expect it to be useful.  Even using traditional register access with C my skills are in question.  Therefore, I will probably be using the FR2111 and its larger memory for my own small projects.

This is not meant to come across as a negative as I am aware of amazing examples of what can be done with 1 K and of course there are those 25 functions in the e-book above.  I have had limited time to explore those and have other pressing matters but hope to come back to them in future.  I did try the SPI_IO_EXPANDER_CCS example with the thought of reproducing the binary counter display discussed above but driven from a master.  Unfortunately I was unsuccessful on my first attempt late last night, possibly due to setting up the master SPI wrong (and being sleepy).

Thanks for reading.  I would be interested if others are using this or other small microcontrollers and in what kind of projects.

Correction:  11/16/2017  Cost table had costs reversed for FR2000 and FR2111, corrected now