OS_Error(OS_ERR_NOT_IN_ISR) 163

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

  • OS_Error(OS_ERR_NOT_IN_ISR) 163

    Hello everybody,

    I'm trying to use embOS on a Toshiba TMPA900CM (ARM926EJ-S Core). The problem is that as I enter the CREATETASK() function / macro OS_Error 163 is called. I debugged the application several times. Here are the functions which are called:

    OS_CREATETASK() => OS_CreateTask_D => OS_AssertISROrTask => OS_GetCPUState. In fact OS_GetCPUState returns 0 and that results in Error Code 163 in OS_AssertISROrTask. I only have the Object-File Version so its difficult to Debug this problem. This is my main.c (as in the documentation)

    C Source Code

    1. #define OS_LIBMODE_D
    2. #include "RTOS.h"
    3. extern OS_GLOBAL OS_Global; // Only for Debugging
    4. OS_STACKPTR int StackHP[128], StackLP[128];
    5. OS_TASK TCBHP, TCBLP;
    6. static void HPTask(void)
    7. {
    8. while(1)
    9. {
    10. OS_Delay(10);
    11. }
    12. }
    13. static void LPTask(void)
    14. {
    15. while(1)
    16. {
    17. OS_Delay(50);
    18. }
    19. }
    20. int main()
    21. {
    22. OS_IncDI();
    23. OS_InitKern();
    24. OS_InitHW();
    25. OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);
    26. OS_CREATETASK(&TCBLP, "LP Task", LPTask, 50, StackLP);
    27. OS_Start();
    28. return 0;
    29. }
    Display All


    My OS_InitHW() function I templated from the TMPA910 Board Support:

    C Source Code

    1. void OS_InitHW(void) {
    2. OS_IncDI();
    3. // OS_ARM_CACHE_Sync(); // Ensure, caches are synchronized
    4. _OS_TIMER_CTRL = 0; // Stop timer
    5. // _OS_CLKCR5 |= 0x0F; // Default value after Reset = fHCLK / 2
    6. _OS_TIMER_LOAD = OS_TIMER_RELOAD; // Set timer interval
    7. _OS_TIMER_CTRL = (1 << 7)
    8. | (1 << 6)
    9. | (1 << 5)
    10. | (0 << 4)
    11. | (0 << 3)
    12. | (0 << 2)
    13. | (1 << 1)
    14. | (0 << 0)
    15. ;
    16. OS_ARM_InstallISRHandler(_OS_TIMER_INT_INDEX, _OS_ISR_Tick);
    17. OS_ARM_ISRSetPrio(_OS_TIMER_INT_INDEX, _INT_PRIORITY_LOWEST);
    18. OS_ARM_EnableISR(_OS_TIMER_INT_INDEX);
    19. //OS_COM_Init();
    20. OS_DecRI();
    21. }
    Display All


    I'm not sure if I called the OS_IncDI() and OS_DecRI() functions in the right way, but I think so because it's the same as in the examples. I also don't understand why the OS want's to be in "ISR State" when I create a task. I would appreciate any help. If you need more source code that's no problem. I will post if necessary. Sorry for my English, I'm practising!

    lowlevel
  • Err 153 Solved now Err 162

    OK,

    I've solved the first problem now. The __low_level_init() function has to return TRUE (!=0). Otherwise the data_initialisation code doesn't execute and in that case OS_Global isn't initialized with proper values.

    After solving that problem there is another one. The Tasks are now initialized but when the firts Timer Interrupt occurs, OS_HandleTick() results in ErrCode 162. I debugged this and found out, that OS_InInt is checked in OS_HandleTick. The variable should be different from zero. The documentation (so far you could name that documentation) says, that OS_EnterInterrupt has to be called before OS_Tick_Handle is called. I called that function but it doesn't change the value of OS_InInt. It only increments the value of OS_Global.Counters.Cnt.DI. Help is appreciated!

    lowlevel
  • Hello,

    please let me know if your using embOS ARM IAR trial version from our webpage or which embOS version you are using.
    We have no BSP for TMPA900 in embOS ARM IAR so far, but it should be similar to BSP for TMPA910.
    With embOS ARM IAR you don't have to call OS_EnterInerrupt()/OS_LeaveInterrupt() becasuse it is already called in OS_irq_handler().
    Please contact us directly (support@segger.com), I am sure that I can help you to solve your problem in short time.

    Best regards,
    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.
  • Hello,

    I now have a workaround for the problem. If I don't use the "DEBUG" Library, but the "Release" one, it works.
    Thank you for your suggestion to email but I'm using IAR PowerPac and I don't know if you are supporting users of IAR too.
    I think my RTOS is running now. Further problems will be posted in the other forums.
  • Hello,

    this is not a smart workaround since you only have disabled the embOS debug tests, which means, that the problem could still exist.
    We can support IAR PowerPac customers when they buy a new Segger support agreement. If not please contact your IAR support.

    Best regards,
    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.