LPTMR keep time and generate hardware trigger in VLPS

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

LPTMR keep time and generate hardware trigger in VLPS

733 Views
ppd
Contributor II

Hi,

I want to generate a hardware trigger every 10ms or so from LPTMR to TSI while the MCU is in VLPS. But I also want to know for how long (measured in microseconds) I've been in VLPS once I get out of it. Can I do both of these things at the same time with the LPTMR? If not, is there any other way of achieving this? I'm using a KL05.

Thanks,

Paul.

0 Kudos
4 Replies

577 Views
mjbcswitzerland
Specialist V

Paul

I would use the RTC (you can also run it from the same clock as the LPTMR) but then has no restrictions, such as the amount of time that it can measure.

http://www.utasker.com/kinetis/KL_RTC.html

Regards

Mark

0 Kudos

577 Views
ppd
Contributor II

Hi Mark,

Unfortunately the RTC increments every second (if external an external 32.768kHz clock is used) or every 32 seconds (if the internal LPO clock is used). Not good enough. I need the time in at least multiple of tens of milliseconds.

I'm afraid I'm going to have to use TPM with external clock source (for lowest power). Unfortunately this means adding an external crystal (which I don't have right now and the PCB is already very crowded) and accepting an additional ~30uA in current consumption to keep the TPM running in VLPS.

Anyone having a better idea?

Thanks!

0 Kudos

577 Views
mjbcswitzerland
Specialist V

Paul

The RTC has a pre-scaler register called RTC_TPR which counts at the clock rate. This allows 1ms resolution from LPO or 30us resolution with external 32kHz.

pastedImage_1.png

I have crossed out the 32kHz clock since it actually increments at the "selected" clock rate.

Beware that the LPO is not very accurate so there may be several % of drift.

Regards

Mark

577 Views
ppd
Contributor II

Ah, I overlooked the prescaler register.... Well then this is just what I want. I'm not looking for accuracy so this is just perfect. Thank very much for your help!

0 Kudos