PIT Does not Seem to Work Properly After Waking from VLPS

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

PIT Does not Seem to Work Properly After Waking from VLPS

Jump to solution
1,769 Views
nick_schneider
Contributor II

When I attempt to initialize the PIT after waking from VLPS, the PIT does not behave how I would expect. From what I can tell, the PIT is taking 18,707 times longer to trigger an interrupt after waking from VLPS when compared to before doing any operation related to VLPS.

I hope the attached code explains what I am attempting to do well enough. I made a barebones program where I use the PIT to wait 1ms. Everything works before I enter VLPS but after I come out of VLPS it is taking 18.707s to do the same wait operation. If I do it with a 2ms baseline it will take 37.413s after VLPS and so on. If I keep the PIT constantly on it seems to interrupt in a consistent manner but if I try to fully init OR just restart the timer using PIT_StartTimer() after VLPS I get this really long wait.  

I would really like to be able to turn off the PIT and only periodically use it otherwise I would just leave it on. I checked everything I could think of after doing the VLPS operation including verifying the power mode state (SMC_GetPowerModeState()), verifying the bus clock rate (CLOCK_GetBusClkFreq()), checking the priority of the PIT irq (NVIC_GetPriority()), calling all initialization functions again, and others but nothing I saw seemed out of place.

Any help would be greatly appreciated.  

Device: MKL16Z128VFM4

Installed SDK: SDK_2.x_MKL16Z128xxx4 version 2.2.0 manifest version 3.0.0

IDE: MCUExpresso version 11.6.0

 

Labels (1)
0 Kudos
Reply
1 Solution
1,705 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Sorry for the delay.

Please try to delete the __WFI(); in Timer_Hal_delay_ms function.

WFI.png

View solution in original post

6 Replies
1,697 Views
nick_schneider
Contributor II

Wow, that seems to have fixed the issue. When I inherited this function I assumed the WFI operation was trivial. Still not sure why there is only an issue after VLPS, but I can go and learn more about WFE and WFI.

Thank you!

0 Kudos
Reply
1,736 Views
nick_schneider
Contributor II

Hey Robin,

I have checked a few more things that you recommended.

 

Is it PEE mode before entering VLPS?

- No, it appears to always be in FEI mode. I checked this before and after going into VLPS by calling CLOCK_GetMode()

 

I have also output the bus clock on the CLKOUT pin on the code I have here locally. I then used an oscilloscope to check the frequency of the clock. Before and after I go into VLPS my oscilloscope is reporting that the frequency is 10.540 MHz which sounded about right to me. 

0 Kudos
Reply
1,706 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Sorry for the delay.

Please try to delete the __WFI(); in Timer_Hal_delay_ms function.

WFI.png

1,736 Views
nick_schneider
Contributor II

Here is a full project that I hope demonstrates what I am trying to do a little better than the previous files. Let me know if there are any issues using this. 

I am still looking into the tips and suggestions mentioned above. 

0 Kudos
Reply
1,737 Views
nick_schneider
Contributor II

Hi Robin,

I will look into getting a complete project set up that I can hand over. Also, I will look into setting the Bus clock to the CLKOUT pin and the related suggestions.

For measuring the time of the PIT, I was measuring the pulse of the LED after power on using an oscilloscope .

0 Kudos
Reply
1,761 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi nick_schneider,

Can you send a complete test project, so that I can test it on FRDM-KL26Z board? I am not able to test your pit_issue_example.c due to lack of some configurations, such as clock configuration, LPTMR settings, etc.
Is it PEE mode before entering VLPS? Note: During exits from LLS or VLPS when the MCG is in PEE
mode, the MCG will reset to PBE clock mode and the C1[CLKS] and S[CLKST] will automatically be set to 2’b10.
The clock source of PIT is Bus clock, please output it to CLKOUT pin. (
SIM_SOPT2[CLKOUTSEL]=010 Bus clock
Configure the PTC3 as CLKOUT function by change the PORTC_PCR3[MUX]=101 Alternative 5
)

Please tell me how to measure time of PIT. Do you measure the time of high pulse at LED after power on? Or measure in debug mode?


Best Regards,
Robin
-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------