how to put contoller in stop mode for 15min with lptimer?

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

how to put contoller in stop mode for 15min with lptimer?

Jump to solution
795 Views
fw01
Contributor II

Hello all,

i am using mk20dxvll7 micro-controller for my project. and i want to put it on stop mode after data posting through GSM and wakeup through lptimer. and i want to put my microcontroller in stop mode for 15min.

From demo code i am able to put contoller in stop mode for 1 min. but not able for 15min.

here is the sequence which i follow in code.

SIM_SCGC5 |= SIM_SCGC5_LPTIMER_MASK; /// Init Clock of LPTIMER.

LPTMR0_CSR = (LPTMR_CSR_TCF_MASK | LPTMR_CSR_TPS(0x00)); /* Clear control register */

LPTMR0_CMR =0xFFFE; /* Compare. */

LPTMR0_PSR = LPTMR_PSR_PRESCALE(0x00) | LPTMR_PSR_PBYP_MASK | LPTMR_PSR_PCS(0x01); /* Set up prescaler register */

LPTMR0_CSR = ( LPTMR_CSR_TPS(0x00) | LPTMR_CSR_TFC_MASK | LPTMR_CSR_TIE_MASK | LPTMR_CSR_TEN_MASK); /* Set up control register */

enable_irq(INT_LPTimer-16);

SIM_SCGC4 |= (uint32_t) SIM_SCGC4_LLWU_MASK;
/* Initialization of the LLWU module */
LLWU_PE1 = 0x00;
LLWU_PE2 = 0x00;
LLWU_PE3 = 0x00;
LLWU_PE4 = 0x00;
LLWU_ME = 0x00;

/* LLWU_FILT1: FILTF=1,FILTE=0,??=0,FILTSEL=0 */
LLWU_FILT1 = LLWU_FILT1_FILTF_MASK | LLWU_FILT1_FILTE(0x00) | LLWU_FILT1_FILTSEL(0x00);
LLWU_FILT2 = LLWU_FILT2_FILTF_MASK | LLWU_FILT2_FILTE(0x00) | LLWU_FILT2_FILTSEL(0x00);
LLWU_RST = LLWU_RST_LLRSTE_MASK | LLWU_RST_RSTFILT_MASK;
LLWU_ME |= (uint8_t) ( LLWU_ME_WUME0_MASK); /// -> Module LPTMR0

SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;

/* Set the VLLSM field to 0b100 for VLLS1 mode - Need to retain state of LPWUI bit 8 */
SMC_PMCTRL = SMC_PMCTRL_STOPM(0x4) ;
SMC_PMCTRL |= SMC_PMCTRL_LPWUI_MASK; //reena
SMC_VLLSCTRL = SMC_VLLSCTRL_VLLSM(1);

stop();

Please check this sequnce. and let me know what should i do to put stop mode continuous for 15min.

Please reply as soon as possible.

Thanks and regards 

Reena

0 Kudos
1 Solution
689 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Reena Patel ,

   You can realize 1 minute, because the LPTMR is 16 bit counter, the max counter is 65536, and you choose LPO=1ms as the LPTMR clock source, then the max time you can realize is 1ms*65536=1.09 minute.

  So, if you want to increase the time, it's easy, you totally can use the LPTMRx_PSR[PRESCALE]=16, then your clock source will be 16*1ms=16ms. Then the mas time should be:16*65536=17.47 minute, larger than your 15 minutes.

  If you want to get 15minutes, you can define the compare register CMR.

  (CMR+1)*16=15*60*1000=>CMR=56249

  So, now, please modify your code:

 LPTMR0_PSR[PRESCALE] =3:Prescaler divides the prescaler clock by 16; glitch filter recognizes change on input pin after 8 rising clock edges.

LPTMR0_CMR[COMPARE]= 56249;

You can try it on your side.

Wish it helps you!

If you still have question about it, please kindly let me know.
Have a great day,
Kerry

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

3 Replies
690 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Reena Patel ,

   You can realize 1 minute, because the LPTMR is 16 bit counter, the max counter is 65536, and you choose LPO=1ms as the LPTMR clock source, then the max time you can realize is 1ms*65536=1.09 minute.

  So, if you want to increase the time, it's easy, you totally can use the LPTMRx_PSR[PRESCALE]=16, then your clock source will be 16*1ms=16ms. Then the mas time should be:16*65536=17.47 minute, larger than your 15 minutes.

  If you want to get 15minutes, you can define the compare register CMR.

  (CMR+1)*16=15*60*1000=>CMR=56249

  So, now, please modify your code:

 LPTMR0_PSR[PRESCALE] =3:Prescaler divides the prescaler clock by 16; glitch filter recognizes change on input pin after 8 rising clock edges.

LPTMR0_CMR[COMPARE]= 56249;

You can try it on your side.

Wish it helps you!

If you still have question about it, please kindly let me know.
Have a great day,
Kerry

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

689 Views
fw01
Contributor II

Hello sir,

Thank you so much for your answer, its work for me.

Now i want to set some little bit critical condition. 

For my project application, where i use mesh concept, where one device will act as master , other 10 device will work as slave.

Master itself send its own sensors data in each 15 min and will go for deep sleep. 

same thing happens with slave devices as well, where slave device collect its sensors data and through RF it will send to master device, because only master device has GSM module, which can only send data at web app.

So i want to add two functionality master device send its own data at each 15min(using lptimer) and master wakes up at slave device RF interrupt and send slave data only. But nothing has to happen with master device timing (LPTIMER).

But i think when device wake up, i think lptimer reset it self. so please instruct me how can i add this kind of mechanism ?

Thanks and Regards,

Reena Patel

0 Kudos
689 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Reena Patel,

   Could you please create a new question post about your new question?

   Then we will help you in your new post.

   Please also share your test result about your new though, Eg, when you use the slave to wake up the master, use which wake up source? After the master wake up, you can check your LPTIMER counter, what the status about it.

  If you create the new post, and still want I to reply you, you can @ kerry zhou.

Thank you!


Have a great day,
Kerry

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos