/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / primer2 shutting down suddenly

Username:     
Password:     
             

Forum

# 1   2009-11-16 11:18:42 primer2 shutting down suddenly

adal
Member
Registered: 2009-04-22
Posts: 32

primer2 shutting down suddenly

Hi,

I bumped in a very strange behaviour of the Primer2(+CircleOs 3.7).

I basically implemented an application requiring significant speed so among the initializations
I added :

            SysTick_CLKSourceConfig( SysTick_CLKSource_HCLK_Div8 );
            SysTick_SetReload( 1 );

....and at the exit from the application I execute the following statements before returning to CircleOs in order to restore normal operation:

            SysTick_CLKSourceConfig( SysTick_CLKSource_HCLK_Div8 );
            SysTick_SetReload( 3000 );

Now, the problem I have since I added those code lines is that as soon as I re-enter the application for the second time the Primer2's power goes down!!!
Primer2 is USB powered and battery looks also loaded, I can run the application one time,
but not the second time in a row without getting a shutdown...
Any clue about what could be wrong???

Thanks,
Adalberto

Offline

 

# 2   2009-11-16 13:09:27 primer2 shutting down suddenly

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: primer2 shutting down suddenly

Adalberto,

The CircleOS contains a power save management (Power handler), that automatically shutdowns the Primer in case of no activity during about 5 mn.
This management is scheduled (as other handlers) by the systick interrupt, so the delay has been cut off when you modified the systick period.
Modify the "shutdwon.c" (v3.7) or "power.c" (>v3.7) file if you want to deactivate it.
Remember that all the handlers of the CircleOS are scheduled by the systick IT, so modify it can lead to strange behaviors.

On the other hand, if you want to accelerate the application calls, you can use the "MENU_SetAppliDivider" ans set the value to 1, in order to call your application every systick.

Yves

Offline

 

# 3   2009-11-16 16:54:55 primer2 shutting down suddenly

adal
Member
Registered: 2009-04-22
Posts: 32

Re: primer2 shutting down suddenly

Hi yrt,

I've been re-working shutdown.c a little bit to avoid falling into a call to SHUTDOWN_Action(), and by the way I also redundantly raised the MAX_TIME_ON from (60*5) to 30000 (but I expect this to be useless after the first action).
Looks like if these pathces are not helping so my new question is if there are other places
within circle that are affecting power on/off, or anything else I forgot to be aware of...

Thanks,
Adalberto

Offline

 

# 4   2009-11-17 07:48:29 primer2 shutting down suddenly

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: primer2 shutting down suddenly

Adalberto,

The "Shutdown action" is only called when these events appear :
- battery low (power handler), to avoid irreversible discharge of the battery,
- inactivity (power handler),
- a long push on the button (button handler).

To be sure, the simplest way is to comment the last SHUTDOWN_Action call in shutdown.c after (On_Time > MAX_TIME_ON ), or put breakpoints to verify which call lead to a shutdown.

Offline

 

# 5   2009-11-17 12:17:00 primer2 shutting down suddenly

adal
Member
Registered: 2009-04-22
Posts: 32

Re: primer2 shutting down suddenly

Yves,

just before my last e-mail I already commented out SHUTDOWN_Action() after if ( On_Time > MAX_TIME_ON ) in shutdown.c but it didn't give results.
Later, I found out that the problem was in button.c (this might be the long button push you refer in your last answer).

I temporarily solved the problem commenting out SHUTDOWN_Action() in button.c, but of course this will make me lose the shutdown on long-press functionality.

Taking a deeper analisys to come up with a cleaner solution I see that SHUTDOWN_Action()
gets called in button.c when the following condition is true:

"( Button_LongCounter > WEIGHTED_TIME(SHUTDOWNCOUNT) )"

with:
-SHUTDOWNCOUNT == 200;
-WEIGHTED_TIME scales up SHUTDOWNCOUNT to TIM2 related values that I don't touch;
-Button_LongCounter increments at sysTick frequency on button press, but I speed up sysTick only after BUTTON_WaitForRelease() and I restore the sysTick frequency on
application exit (back to Circle3.7Os). So if it is this variable (Button_LongCounter ) reaching
the limit, I don't know how/why it happens...

I don't know what else could be causing the unwanted shutdowns that I get from the
second time I call the application given that I never hold the button press to shutdown on purpose.

What else could I be missing?

Thanks,
Adalberto

Offline

 

# 6   2009-11-17 14:16:05 primer2 shutting down suddenly

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: primer2 shutting down suddenly

I don't know what happends, but I'm not sure to undersdtand when you modify the systick frequency. Could you precise it ?

May be you can put a breakpoint on the variable Button_LongCounter on Write event, in order to try to see when this variable is modified, if it does.

Offline

 

# 7   2009-11-17 16:50:31 primer2 shutting down suddenly

adal
Member
Registered: 2009-04-22
Posts: 32

Re: primer2 shutting down suddenly

Yves,

the sysTick frequency is boosted once at the very first runs of the Application_Handler as soon as a 0x79 byte is detected on the USART2 rx (in response of a 7F transmitted in the Application_Ini).

I display Button_LongCounter an I see it exceeds it's limit in button.c;
I have the feeling that the problem is related to the fact that the button is still pressed at
the time where sysTick frequency is increased so Button_LongCounter increments quickly,
a solution is to raise SHUTDOWNCOUNT or to wait a little more time before boosting sysTick frequency.

The only thing I DON'T understand is that I don't get into this the first time which makes me
think that probably the first time I select an application from CircleOs (after Primer2 reset) are there some sort of initializations adding a helpful delay for this case (before sysTick boost). Is this statement true or it's just false ??

(...P.S. I'm not very familiar with Circle OS App. scheduling yet)

Thanks,
Adalberto

Offline

 

Board footer