Other Initialization (WDT, PMM)
Initialization Summary (template)
To some of you the following template may seem obvious, but we thought it might be handy to
provide a template, of sorts, for a main() function in an MSP430 program.
Summary: Initializing MSP430
#include <driverlib.h>
void main(void) {
// Setup/Hold Watchdog Timer (WDT+ or WDT_A)
initWatchdog();
// Configure Power Manager and Supervisors (PMM)
initPowerMgmt();
// Configure GPIO ports/pins
initGPIO();
// Setup Clocking: ACLK, SMCLK, MCLK (BCS+, UCS, or CS)
initClocks();
//----------------------------------------------------------
// Then, configure any other required peripherals and GPIO
...
while(1) {
...
}
}
Notice that there are function calls provided for many of the initialization steps discussed in this
chapter. Of course, it’s up to you to provide the necessary code for each of these functions. The
following lab exercises will provide some examples of these functions – which we’ll continue to
build upon in future chapters.
4 - 40 MSP430 Workshop - MSP430 Clocks & Initialization