Posts: 118
Registered: ‎12-27-2016
Accepted Solution

EMU_EnterEM2() time from entry to "WFI" instruction

I just measured the number of machine cycles between the time that I enter the EMU_EnterEMU2 subroutine, and the time that the WFI instruction is executed. The time is 258 machine cycles or a little over 8uS at 32MHZ core clock !  Since I am burning full power during this additional 8uS, I am becoming concerned.


Single stepping thru the code, I see that the code is configuring/reconfiguring the DC-DC converter (again). What is going on here ?  Is this code necessary ?  Why ? 


I am not doing the restore on exit from EM2 either since I am already using the HFRCO oscillator.


Is the DC-DC configured for something different after exit from EMU2 if I don't use the restore function ?



Posts: 343
Registered: ‎03-03-2015

Re: EMU_EnterEM2() time from entry to "WFI" instruction

Hi gahelton1,


The DC-DC converter can be changed to different modes based on your power and noise requirements (which may be different in EM2).  See AN948 for more information.  Also see errata DCDC_E202 and DCDC_E203, the workaround is to set the DCDC to low noise mode when entering EM2 to reduce the output dip that occurs.


Keep in mind the emlib function is intended to cover all use cases.  You can write your own function if you like, to reduce the amount of time it takes to enter EM2.  




Posts: 579
Registered: ‎09-18-2015

Re: EMU_EnterEM2() time from entry to "WFI" instruction

Hi @gahelton1,


Also, are you compiling code in the Debug or Release configuration?


Debug includes a fair bit of overhead to permit stepping correspondence between C instructions and the underlying assembly language as well as constructs necessary for local variable visibility.


Try compiling your code in the Release configuration and seeing what happens to the EM2 entry time.