Thanks for the prompt and helpful reply. I realized that I misinterpreted what was going on in the original version of the code in the lines associated with the Reset Control.
Normally, with an "&=" I would expect to see a tilde to invert the bitmask. If forgot to do that and it resulted in a number of other registers getting reset, instead of just WKT.
I finished the modification of the original code to only use the defintions/macros in lpc802.h. Here it is, and it works, with an ISR period of about 100 ms.
// based on LPC802_Project_NXPCode_Ctimer_Ex.c
//
// ------------------------------------------------------------------------------------
#define WKT_FREQ 1000000 // Use if the WKT is clocked by the LPOSC
//#define WKT_FREQ 937500 // Use if the WKT is clocked by the 15 MHz FRO, via the div-by-16 WKT divider
#define WKT_RELOAD 100000 // Reload value for the WKT down counter
#define WKT_INT_FREQ (WKT_FREQ/WKT_RELOAD) // INterrupt frequency of the WKT.
#define LED_USER1 (8) // PIO0_8_RXD
#include "LPC802.h"
// prototypes
void WKT_Config();
// main routine
//
int main(void) {
// WKT: Wake Timer configuration
WKT_Config();
while(1) { // Have a tequila
asm("NOP");
} // end of while 1
} // end of main
// Function name: WKT_Config
// Description: Initialize a GPIO output pin and the WKT, then start it.
// Parameters: None
// Returns: Void
// Source: Ch. 18 of the User Manual (UM11045)
void WKT_Config() {
// --------------------------------------------------------
// Step 1. Make an LED turn on. Checks that board is up and running.
// Enable GPIO for the LED.
SYSCON->SYSAHBCLKCTRL0 |= (SYSCON_SYSAHBCLKCTRL0_GPIO0_MASK);
// GPIO to Output.
GPIO->DIRSET[0] = (1UL<<LED_USER1);
// Turn on the LED.
GPIO->CLR[0] = (1UL<<LED_USER1);
// --------------------------------------------------------
// Step 2: turn on the Wake-up Timer (WKT) enabling clock.
SYSCON->SYSAHBCLKCTRL0 |= (SYSCON_SYSAHBCLKCTRL0_WKT_MASK);
// --------------------------------------------------------
// Step 3: disable the vector lookup for WKT.
NVIC_DisableIRQ(WKT_IRQn); // turn off the WKT interrupt.
// --------------------------------------------------------
// Step 4: Turn on the Low Power Oscillator's power supply.
// bit 6 to 0 in order to turn it ON. (Active low)
// old version: LPC_SYSCON->PDRUNCFG &= ~(LPOSC_PD); // Power-up the LPOSC
SYSCON->PDRUNCFG &= ~(SYSCON_PDRUNCFG_LPOSC_PD_MASK);
// --------------------------------------------------------
// Step 5: Enable the LPOSC clock to the WKT. (Bit 1 to 1)
// old version: LPC_SYSCON->LPOSCCLKEN |= 1<<WKT_CLK_EN; // Enable the LPOSC clock to the WKT
SYSCON->LPOSCCLKEN |= (SYSCON_LPOSCCLKEN_WKT_MASK);
// --------------------------------------------------------
// Step 6: Reset the WKT.
// Set bit 9 to 0: assert (i.e. "make") the WKT reset
// Set bit 9 to 1: clear the WKT reset (i.e. "remove" reset)
// the original version was broken here. Missing ~ on first line. Too much ~ on 2nd line.
// without this fix, other modules were getting reset and resulting in hard fault.
SYSCON->PRESETCTRL0 &= ~(SYSCON_PRESETCTRL0_WKT_RST_N_MASK); // Reset the WKT
SYSCON->PRESETCTRL0 |= (SYSCON_PRESETCTRL0_WKT_RST_N_MASK); // clear the reset.
// --------------------------------------------------------
// Step 7: Load the timer
// --------------------------------------------------------
// Select the LPOSC as the WKT clock source (0b0001)
// Bit 0 (CLKSEL) to 1 for Low Power Clock
// BIt 1 (ALARMFLAG) read flag. If 1, an interrupt has happend. if 0, then no timeout.
// Bit 2 (CLEARCTR). Set to 1 to clear the counter.
// Bit 3 (SEL_EXTCLK). Set to 0 for internal clock source.
//
//LPC_WKT->CTRL = LOW_POWER_OSC<<WKT_CLKSEL;// Select LPOSC as WKT clock source (approx. 1 MHz)
WKT->CTRL = 0x00000001;
// need to un-hardcode the line above (line 90.)
// load the timer count-down value. (The "Timeout value")
WKT->COUNT = WKT_RELOAD; // Start the WKT, counts down WKT_RELOAD clocks then interrupts
// Enable the IRQ
NVIC_EnableIRQ(WKT_IRQn); // Enable the WKT interrupt in the NVIC
}
// Function name: WKT_IRQHandler (interrupt service routine)
// Description: WKT interrupt service routine.
// Toggles a pin, restarts the WKT.
// Parameters: None
// Returns: Void
void WKT_IRQHandler(void) {
WKT->CTRL |= (1<<WKT_CTRL_ALARMFLAG_SHIFT); // Clear the interrupt flag
WKT->COUNT = WKT_RELOAD; // Restart the WKT
// Toggle the LED
GPIO->NOT[0] = (1UL<<LED_USER1);
return;
}