[SOLVED] OS_ERR_ILLEGAL_OUT_ISR in OS_TICK_Handle

  • Hello Everyone,

    I'm having a strange issue with a new implementation with embOS 4.26, STM32L4 uc and GCC 8.0-2019q3. The problem is with the OS_TICK_Handle function that is causing OS_ERR_ILLEGAL_OUT ISR error as soon as it is called. SysTick_Handler function is directly called from the isr vector and is the hardware systick timer.


    The same code above is working fine in other projects.

    The workaround I found is to call the SysTick_Handler function from "OS_CallNestableISR" and now I'm wondering how it could have worked in the previous projects and why my usual implementation is not working.

    Thanks

  • Hello,

    While we're not aware of any issues regarding OS_TICK_Handle(), we'd of course like to help you in finding the cause for the observed behavior.

    Generally speaking, OS_ERR_ILLEGAL_OUT_ISR is indicated whenever embOS assumes that an API function that may only be called from an ISR was called from a context that is not an ISR.
    This is done by checking the variable OS_Global.InInt, which should have been incremented before by calling either OS_EnterNestableInterrupt() or OS_EnterInterrupt().
    This, in return, would indicate that your code does not actually call either of these functions, though the code snippet provided above does clearly show a call to OS_EnterNestableInterrupt(). Alternatively, OS_Global.InInt may also have been corrupted by the application, which could then result in the exact same behavior. Hence, could you please check if the code gets in fact executed and OS_Global.InInt gets incremented from 0 to 1?

    Calling OS_CallNestableISR() - while it seems to solve the problem - unfortunately is not a proper solution. That function is mandatory to use for certain architectures, but Cortex-M is none of these architectures. Since the function merely calls OS_EnterNestableInterrupt() and then executes the given ISR routine, the sudden change in behavior would once more indicate that OS_EnterNestableInterrupt() was not called explicitly.

    By the way: Since you're working with embOS 4.26, you may also want to have a look at https://www.segger.com/products/rtos/…s-cortex-m-gcc/ , for more recent versions of embOS for Cortex-M and GCC do provide several start projects for STM32L4 devices that could serve as a starting point for your own project. Also, please have a look into the release notes on that page, too: Recent versions contain various new features and improvements that could be of interest to you as well, hence you might want to consider updating embOS to one of these versions.

    Please let me know if I can be of any further help.

    Best regards,
    Martin

    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: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Dear Martin,

    thanks for your reply. I've checked the OS_Global struct and realize that this struct was not aligned between our library that contains the embos and the application that uses such library.

    More in detail we were using SYMBOLS+=-DOS_PROFILE=0 in the library while SYMBOLS+=-DOS_LIBMODE_DP in the application. The structure below was then not consistent in the whole project and causes the error.

    Thanks a lot for your support.

  • Glad you're up and running again!
    We'll consider this thread closed now.

    Best regards,
    Martin

    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: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!