I'm trying to get S32K waked-up from VLPS using CMP in round robin mode. Here are the steps that I did:
- Configure SIRC divider to 2 and enable it, so I have 4 Mhz as SIRCDIV2 CLK.
- Enable clock gated LPTMR0.
- LPTMR0 is configured tu use SIRCDIV2 clk in free runing counter with CMR=0
- Configure CMP0 in round robin mode with:
/* IN0, from the 8-bit DAC output
* IN1, from the analog 8-1 mux
* Enable Channel 0, 1 and 5 for round robin
* Enable DAC
* Supply voltage reference is Vin1
* 1 round-robin clock cycle later, the result is sampled
* Compare result is 0 initial values for all channels
* From datasheet: Initialization delay for CMP in Low-speed mode is 30us max
* round robin clock is 2 MHz --> INITMOD = 30000/500 = 60
* Low Speed (LS) comparison mode is selected.
* Analog Comparator is enabled
* Clear CMP inputs changed flags
* Enable Round robin
* Enable round robin interrupt
CMP0->C2 |= CMP_C2_RRE(1) | CMP_C2_RRIE(1);
/* Clear TCF */
LPTMR0->CSR |= LPTMR_CSR_TCF(1u);
/* Enable LPTMR0 */
LPTMR0->CSR |= LPTMR_CSR_TEN(1u);
Am I missing something?
Is there any example how to configure LPTMR0 to trigger CMP in round robin?
Solved! Go to Solution.
You may refer to the example below.
Why do you set CMR = 0?
In this case the trigger will remain asserted.
Yes I found out that this was a mistake. I fixed the issue by Setting CMR to a value to define the trigger period. The CMP now works correctly in round robin mode. I can wake up the MCU from VLPS when cmp inputs change..