(Optional) Lab 4b – Exploring the Watchdog Timer
16. Build the code to test that is error-free (syntax wise).
Did you get an error? Unless you’re really experienced and changed one other item, you
should have received this error:
Where are these values defined? ______________________________________________
17. Include driverlib.h in your hello.c file.
Yep, when we added the driverlib code, we needed to add the driverlib header file, too.
Actually, you can replace the msp430.h file with driverlib.h because the latter
references the former.
When complete, your code should look similar to this:
#include <stdio.h>
#include <driverlib.h>
uint16_t count = 0;
/*
* hello.c
*/
int main(void) {
// WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
WDT_A_watchdogTimerInit( WDT_A_BASE,
WDT_A_CLOCKSOURCE_ACLK,
WDT_A_CLOCKDIVIDER_64 ); //WDT clock input divisor
//WDT_A_CLOCKDIVIDER_512 ); //Here are 3 (of 8) div choices
//WDT_A_CLOCKDIVIDER_32K );
WDT_A_start( WDT_A_BASE );
while (1) {
count++;
printf("I called this %d times\n", count);
}
}
18. Build the code; fix any errors.
19. Launch the debugger and run the program. Write down the results.
How many times does printf() run before the count restarts? Terminate, change divisor, and
retest.
(This is why we put 2 commented-out lines in the code.)
Number of times printf() runs before watchdog reset:
WDT_A_CLOCKDIVIDER_64: ________________________________________________
WDT_A_CLOCKDIVIDER_512: _______________________________________________
WDT_A_CLOCKDIVIDER_32K: _______________________________________________
4 - 56 MSP430 Workshop - MSP430 Clocks & Initialization