cembeddedmicrocontrollermsp430code-composer

Using the terminal to return "hello world" with MSP430 Launchpad and CCStudio


I am trying to run "Hello world", the most simple and basic code there is, on an MSP430 Launchpad (specifically, the MSP430FR5994 Launchpad). I want to run this and have it be displayed on the CCStudio console or another screen. However, I can't find any information on running "hello world" for the Launchpad and having it print on a computer screen.

This feels like it should be simple, but I can't seem to find an explanation anywhere.

Current code, which includes blinking the lights:

#include <msp430.h>
#include <stdio.h>

int main(void) {
    WDTCTL = WDTPW | WDTHOLD;// Stop watchdog timer
    P1OUT &= ~BIT0;    // Meant to clear P1
    P1DIR = 0b00000010;     // Set P1.0 to output direction, p.131

    unsigned int i;   //Delay variable
    PM5CTL0 &= ~LOCKLPM5; //The datasheet told me to include it. Haven't found out why the datasheet asked me to do this.

    printf("Not C programming again!\n");

    while(1)
    {
        for(i=0;i<20000;i++){
        }

        P1OUT = 0x02;    //Turn on Port 1.1
        for(i=0;i<20000;i++){
        }

        P1OUT = 0x01;   //Turn on Port 1.0
    }
    return 0;
}

I am trying to do this as a way to familiarize myself with the board and to get an easier method of debugging. I eventually want to create a low frequency triangle wave, and compare two analog inputs with the comparator then displaying that comparator information on a computer screen. Don't know how this helps but better to let you know.

Please let me know if this question needs more explanation. I apologize if this question turns out to be mindbogglingly simple, I have spent hours looking for explanations and only found blinking lights.


Solution

  • I found out why my terminal was not displaying the text. This is an issue with dynamic memory allocation, where not enough of it was allocated for printf to be successfully run. As it turns out printf is more computationally expensive than I could have expected.

    In order to deal with the allocation issue, the heap size (explained in page 155 of the MSP C Compiler Manual) needs to be increased to 320. This can be done by (I am using CCStudio 11.1) opening your project or a file in your project, going to Project (which is on the top bar), opening properties, and opening Build/MSP430 Linker/Basic Options.

    It's very important to use the properties in Project instead of the one in File, as the properties in File does not contain the linker.

    enter image description here enter image description here

    If it works, the printed text should come out of a CIO terminal.