What is permitted (or not permitted) in timer callbacks

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • What is permitted (or not permitted) in timer callbacks

    I didn't find a clear delineation between what embOS APIs are safe to call in a timer callback and which are not. From the embOS_Generic.pdf, i see the following:
    Timer routines are similar to interrupt routines; they have a priority higher than the priority of all tasks. For that reason they should be kept short just like interrupt routines.

    Are there APIs that are unsafe to call since we're not in a task context? Clearly it doesn't make sense to call something that might potentially block, but are there other considerations? Often RTOS documentation will explicitly indicate which APIs are unsafe to use in callbacks (and ISRs) - usually there's only a subset of APIs that are safe.


  • We added some columns to the API tables in the last generic embOS manual. You find there the information which embOS API function is allowed to call from main, task, timer callback or interrupt.

    You can download the new manual at segger.com/cms/admin/uploads/p…UM01001_embOS_Generic.pdf
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Fantastic - thanks for the updated docs. This will be a big help. It's great when a vendor is a couple steps ahead of me.

    Now, by any chance does the debug version of the OS attempt to check if an API is being used in an invalid context and drop into OS_Error() if so? I think this would help me ferret out some bugs in the code base I'm working on, so if that's not there consider this post an enhancement request.
  • Yes! This is also included in embOS!

    Nearly all API functions checks if this is a allowed call. If it is not you run into OS_Error() and get a error number which reports what was going wrong. With your call stack debugger window you can see which
    function made the unlegal call.

    Which embOS version do you use? Are you still in support? I can check if this is already included in your embOS version and if not and your are still in support you will get an update.

    --Til
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • I already hook into OS_Error() for helping with detecting bugs during development. We're currently using embOS 3.60d which I know is pretty old. The project will soon update to 3.80h which we have already downloaded (I think this is a pretty recent version). I'm not sure if we're still on support - I'll follow up on that from this end.

    Thanks for the information on all this.