Lab 2 – CCSv5 Projects
MSP430 Workshop - Programming C with CCS 2 - 35
11. Explore source code in hello.c.
Open the file, if it’s not already open.
Double-click on hello.c in the Project Explorer window
We hope most of this code is self-explanatory. Except for one line, it’s all standard C code:
#include <stdio.h>
#include <msp430.h>
/*
* hello.c
*/
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
printf("Hello World!\n");
return 0;
}
The only MSP430-specific line is the same one we examined in the chapter discussion:
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
As the comment indicates, this turns off the watchdog timer (WDT peripheral). As we’ll learn
in Chapter 4, the WDT peripheral is always turned on (by default) in MSP430 devices. If we
don’t turn it off, it will reset the system – which is not what we usually want during
development (especiall during ‘hello world’).