SD card interface
Watchdog/watchdog.cpp@0:22612ae617a0, 2012-10-08 (annotated)
- Committer:
- lharoon
- Date:
- Mon Oct 08 11:14:07 2012 +0000
- Revision:
- 0:22612ae617a0
1st edition
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lharoon | 0:22612ae617a0 | 1 | #include "mbed.h" |
lharoon | 0:22612ae617a0 | 2 | |
lharoon | 0:22612ae617a0 | 3 | // Loads watchdog timer with TC value |
lharoon | 0:22612ae617a0 | 4 | void feed() { |
lharoon | 0:22612ae617a0 | 5 | LPC_WWDT->FEED = 0xAA; |
lharoon | 0:22612ae617a0 | 6 | LPC_WWDT->FEED = 0x55; |
lharoon | 0:22612ae617a0 | 7 | } |
lharoon | 0:22612ae617a0 | 8 | |
lharoon | 0:22612ae617a0 | 9 | // Ref. UM10462.pdf chapter 17 |
lharoon | 0:22612ae617a0 | 10 | void WDTInit() { |
lharoon | 0:22612ae617a0 | 11 | // Power on interface... |
lharoon | 0:22612ae617a0 | 12 | LPC_SYSCON->SYSAHBCLKCTRL |= (0x1 << 15); |
lharoon | 0:22612ae617a0 | 13 | |
lharoon | 0:22612ae617a0 | 14 | // Power on watchdog oscillator |
lharoon | 0:22612ae617a0 | 15 | LPC_SYSCON->PDRUNCFG &= 0x3F; |
lharoon | 0:22612ae617a0 | 16 | |
lharoon | 0:22612ae617a0 | 17 | // Select watchdog oscillator for WWDT clock source |
lharoon | 0:22612ae617a0 | 18 | LPC_WWDT->CLKSEL = 0x1; |
lharoon | 0:22612ae617a0 | 19 | |
lharoon | 0:22612ae617a0 | 20 | uint32_t clk = SystemCoreClock / 16; |
lharoon | 0:22612ae617a0 | 21 | LPC_WWDT->TC = 0xfff;//10 * clk; |
lharoon | 0:22612ae617a0 | 22 | |
lharoon | 0:22612ae617a0 | 23 | // Enable WWDT. The timer will not begin until the |
lharoon | 0:22612ae617a0 | 24 | // proper feed sequence is loaded. |
lharoon | 0:22612ae617a0 | 25 | LPC_WWDT->MOD = 0x3; |
lharoon | 0:22612ae617a0 | 26 | |
lharoon | 0:22612ae617a0 | 27 | feed(); |
lharoon | 0:22612ae617a0 | 28 | #if 0 |
lharoon | 0:22612ae617a0 | 29 | printf("CLKSEL->0x%x TC->0x%x MOD->0x%x FEED->0x%x\n", LPC_WWDT->CLKSEL, LPC_WWDT->TC, LPC_WWDT->MOD, LPC_WWDT->FEED); |
lharoon | 0:22612ae617a0 | 30 | printf("clk->%d\n", clk); |
lharoon | 0:22612ae617a0 | 31 | #endif |
lharoon | 0:22612ae617a0 | 32 | } |