cancel
Showing results for 
Search instead for 
Did you mean: 

Does STM run in HALT0 mode?

davedave95
Associate III
Posted on February 14, 2017 at 10:39

Hello,

Our application on the SPC560P44L3 switches to HALT0 mode in the idle loop for power saving. The PIT is configured to wakeup the CPU every msec for handling timers, which works just fine.

Now I'd like to configure the free running STM for highres time keeping, but it seems that during HALT0 state the STM counter does not increment.

Unfortunately I'm not able to provide a small test program, as the logic for event handling, timers and power saving is scattered throughout the project. Basically what I do to reproduce this is:

  • Program the PIT for 1Khz timer interrupts
  • Read STM timer -> t1
  • Wait for interrupts by doing SetRunMode(SPC5_RUNMODE_HALT0)
  • Read STM timer -> t2

System clock is set to 16MHz, STM divider to 1, so I'd expect (t2-t1) to be 16e6/1000 = 16e3. Instead, the number is much smaller and varies. If however I change the line with SetRunMode() to asm('wait'), the results are exactly as expected.

HALT0 mode is configured like this:

#define SPC5_ME_HALT0_MC_BITS               (0UL | SPC5_ME_MC_MVRON | SPC5_ME_MC_DFLAON_LP | SPC5_ME_MC_CFLAON_LP | SPC5_ME_MC_IRCON | SPC5_ME_MC_PLL0ON | SPC5_ME_MC_XOSC0ON | SPC5_ME_MC_IRCON | SPC5_ME_MC_SYSCLK_FMPLL0)

I'm probably missing something in the datasheet about clock gating to the STM, but I'm not able to find a ME_PCTLx register which gates the STM clock.

Any hints much appreciated,

4 REPLIES 4
Erwan YVIN
ST Employee
Posted on February 14, 2017 at 11:28

Hello Gert ,

we have developped a similar application in 

SPC560Dxx_RLA WKPU API Test Application for Discovery

if STM does not increase in HALT0

i think that you have not configured properly your PeripheralClockMode on LP

SPCSetPeripheralClockMode(PCTL_STM,

SPC5_ME_PCTL_RUN(Y) | SPC5_ME_PCTL_LP(X));

  Best regards

                Erwan

Posted on February 14, 2017 at 11:39

That's what I was thinking, but the problem is that the datasheet does not list a PCTL register for the STM at all. So the question is actually: is there a PCTL register for gating the STM on the SPC560P44L3, and if yes, which one is it?

Posted on February 14, 2017 at 14:16

Hello Gert ,

Yes , i have missed the PCTL

There is no PCTL associated

STM is stopped during HALT0.

better to use eTimer or PIT (an other channel)

         Best regards

                       Erwan

davedave95
Associate III
Posted on February 14, 2017 at 15:17

Ok, that's a clear answer. Thanks!