Using CMP in round robin/trigger mode to wake-up S32K from VLPS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using CMP in round robin/trigger mode to wake-up S32K from VLPS

Jump to solution
2,651 Views
youssef
Contributor II

Hi,

 

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?

 

Thanks

Youssef

1 Solution
2,160 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

You may refer to the example below.

https://community.nxp.com/docs/DOC-335759 

Regards,

Daniel

View solution in original post

3 Replies
2,161 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

You may refer to the example below.

https://community.nxp.com/docs/DOC-335759 

Regards,

Daniel

2,160 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi, 

Why do you set CMR = 0?

In this case the trigger will remain asserted.

Regards,

Daniel

2,160 Views
youssef
Contributor II

Hi Daniel,

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..

Regards,

Youssef

0 Kudos
Reply