I am using a FRDM-MCXN947 board with the MCU expresso SDK and am trying to get LPTRM0 to be clocked at 12MHz.
I have successfully run the lptmr_cm33_core0 demo project which runs at 16KHz.
I modified the example as follows:
1 - Change the system clock to be the FRO12M clock (I don't think this is required but I want to run the system at 12MHZ to save power).
void BOARD_InitBootClocks(void)
{
// BOARD_BootClockPLL150M();
BOARD_BootClockFRO12M();
}
2 - add the line lptmrConfig.prescalerClockSource = kLPTMR_PrescalerClock_0; to select the 12MHz clock. Based on table 463 from the manual
spgeorge2006_0-1744880478717.png
LPTMR_GetDefaultConfig(&lptmrConfig);
lptmrConfig.prescalerClockSource = kLPTMR_PrescalerClock_0;
/* Initialize the LPTMR */
LPTMR_Init(DEMO_LPTMR_BASE, &lptmrConfig);
3 - change LPTMR_SOURCE_CLOCK define to 12000000 to keep the example timings the same
#define LPTMR_SOURCE_CLOCK (12000000)//(16000)
I then ran the example and expected it to run the same as before but using the 12MHz clock, unfortunately the timer does not seem to be counting up. I confirmed this by opening a register view in the debugger and typing a value into the CNR register. On the working example this caused the CNR to update with the current count value, on the 12MHz version the CNR value stays at 0.
The registers look like they are set up correctly:
spgeorge2006_1-1744881104141.png
I assume I am missing a step somewhere but I have read through the manual and cannot see anything in the syscon register or anywhere else that I need to do to select the LPTMR0 clock.
If anyone can tell me what I am doing wrong it would be appreciated.