I've used up all the "good" timers on my LPC11e68, so I need to set up the SCT to do a simple match for microseconds into the future and trigger an IRQ - no repeating, PWM, output, input, etc. just a match.
The driver code seems to be missing some interfaces, because I can set the match register, and clear the counter, but I never get my interrupt.
static void setup_timer(void)
{
Chip_SCT_Init(LPC_SCT1);
Chip_SCT_Config(LPC_SCT1, SCT_CONFIG_32BIT_COUNTER | SCT_CONFIG_CLKMODE_BUSCLK);
Chip_SCT_SetPrescale(LPC_SCT1, TIMER_MICROSECONDS - 1);
NVIC_SetPriority(SCT0_1_IRQn, 2);
NVIC_ClearPendingIRQ(SCT0_1_IRQn);
NVIC_EnableIRQ(SCT0_1_IRQn);
}
static void start_timer(uint32_t match_value)
{
Chip_SCT_SetControl(LPC_SCT1, SCT_CTRL_HALT_L);
Chip_SCT_SetCount(LPC_SCT1, 0); // You can only write the count when the counter is halted.
Chip_SCT_SetMatchCount(LPC_SCT1, 0, match_value);
Chip_SCT_EnableEventInt(LPC_SCT1, SCT_EVT_0);
Chip_SCT_ClearControl(LPC_SCT1, SCT_CTRL_HALT_L);
Chip_SCT_SetControl(LPC_SCT1, SCT_CTRL_CLRCTR_L);
}