Discussion Forum

os_mbx_wait get how long has sleep

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
R M
Posted
2-Dec-2008 20:48 GMT
Toolset
ARM
New! os_mbx_wait get how long has sleep

Hello

How can I know how many ticks the os_mbx_wait function slept before the message has been received? So when the return code is OS_R_MBX, how can I calculate the wait period?

Regards

Read-Only
Author
Per Westermark
Posted
2-Dec-2008 21:20 GMT
Toolset
ARM
New! RE: os_mbx_wait get how long has sleep

What is your reason for needing to know?

I normally always design in an uptime counter in my applications, so I know how long since last reboot. It might be a two-level construct with one 32-bit counter keeping track of seconds and another keeping time in maybe 10ms resolution. Or I may peek at a running timer to get us or better resolution.

With a two-level construct, you have to be a bit careful so you don't get a turn-over of the fast value in between sampling the two values.

Read-Only
Author
R M
Posted
2-Dec-2008 21:30 GMT
Toolset
ARM
New! RE: os_mbx_wait get how long has sleep

I need this information for my own timers implementation. I wait for messages using 'os_mbx_wait' and I need to know how long the wait took in order to calculate the timer expiration. If there is no other option I will add an uptime counter as you suggested.

Read-Only
Author
R M
Posted
3-Dec-2008 12:54 GMT
Toolset
ARM
New! RE: os_mbx_wait get how long has sleep

How do you implement your uptime counter? I mean where do you increment it?
I tried to use os_tmr_create/os_tmr_call but this is just a one shot timer not a periodic one, and I cannot call the os_tmr_create function from os_tmr_call to reactivate it
I tried also to use my SysTick_Handler which calls the SysTick_Handler exported by RTX but the execution stop into a hardware-fault

Regards

Read-Only
Author
Guenter Kollmann
Posted
3-Dec-2008 15:09 GMT
Toolset
ARM
New! RE: os_mbx_wait get how long has sleep

Have you read this? (and following pages....)
Common timeslice is 10ms ... but changeable.
http://www.keil.com/support/man/docs/rlarm/rlarm_ar_timer_tick.htm

.

And You can use (like Per said) an own timer with interrupt beside RTX.

Read-Only
Author
R M
Posted
3-Dec-2008 20:32 GMT
Toolset
ARM
New! RE: os_mbx_wait get how long has sleep

Finally I have used TIM1.

Thanks

Next Thread | Thread List | Previous Thread Start a Thread | Settings