OS_ERR_ILLEGAL_OUT_ISR and OS_ERR_NOT_IN_ISR OS error in PIT handler (OS_TICK_Handle)

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

  • OS_ERR_ILLEGAL_OUT_ISR and OS_ERR_NOT_IN_ISR OS error in PIT handler (OS_TICK_Handle)

    Hello All,

    Here is my code:

    Source Code

    1. int main(void) {
    2. OS_IncDI(); /* Initially disable interrupts */
    3. OS_InitKern(); /* Initialize OS */
    4. OS_InitHW(); /* Initialize Hardware for OS */
    5. // BSP_Init(); /* Initialize LED ports */
    6. /* You need to create at least one task before calling OS_Start() */
    7. OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);
    8. OS_CREATETASK(&TCBLP, "LP Task", LPTask, 50, StackLP);
    9. OS_DecRI();
    10. OS_Start(); /* Start multitasking */
    11. return 0;
    12. }
    Display All


    In OS_InitHW(); I have configured PIT like below:

    Source Code

    1. void OS_InitHW(void) {
    2. OS_IncDI();
    3. OS_ARM_CACHE_Sync(); // Ensure, caches are synchronized
    4. /* Initialize PIT as OS timer, enable timer + timer interrupt */
    5. // AT91C_BASE_PITC->PITC_PIMR = ((OS_TIMER_RELOAD & 0x000FFFFF) | (1uL << 25) | (1uL << 24));
    6. // OS_ARM_InstallISRHandler(AT91C_ID_SYS, _OS_SystemIrqhandler);
    7. // OS_ARM_EnableISR(AT91C_ID_SYS);
    8. AT91C_BASE_PMC->PMC_PCER |= (1 << AT91C_ID_SYS);
    9. AT91C_BASE_PITC->PITC_PIMR =((OS_TIMER_RELOAD & 0x000FFFFF) );
    10. AT91C_BASE_PITC->PITC_PIMR |= AT91C_PITC_PITEN; //24
    11. AT91C_BASE_AIC->AIC_IDCR |= (1 << AT91C_ID_SYS);
    12. AT91C_BASE_AIC->AIC_IDCR |= (1 << AT91C_ID_SYS);
    13. AT91C_BASE_AIC->AIC_SMR[AT91C_ID_SYS]= 0x04;//(AT91C_AIC_SRCTYPE_INT_EDGE_TRIGGERED | OS_TICK_IPL);
    14. AT91C_BASE_AIC->AIC_SVR[AT91C_ID_SYS] = (unsigned int)_OS_SystemIrqhandler;
    15. AT91C_BASE_AIC->AIC_ICCR |= (1 << AT91C_ID_SYS);
    16. AT91C_BASE_AIC->AIC_IECR |= (1 << AT91C_ID_SYS); // IntrEnableMask |= 1 << AT91C_ID_SYS;
    17. AT91C_BASE_PITC->PITC_PIMR |= AT91C_PITC_PITIEN; //25 //enable PIT Interrupt
    18. AT91C_BASE_PITC->PITC_PIMR |= AT91C_PITC_PITEN; //24 //Enable PIT
    19. // OS_COM_Init(); //thios has no effect on behavior
    20. OS_DecRI();
    21. }
    Display All


    PIT interrupt handler gets called successfully, But while executing OS_TICK_Handle(); OS error occured OS_ERR_ILLEGAL_OUT_ISR.

    Source Code

    1. static void _OS_SystemIrqhandler(void) {
    2. volatile unsigned int unPitCnt = (AT91C_BASE_PITC->PITC_PIVR >> (AT91C_PITC_PICNT));
    3. if ( unPitCnt ) { // new tick
    4. OS_TICK_Handle();
    5. }
    }

    Documentation says:


    162
    OS_ERR_ILLEGAL_OUT_ISR


    embOS timer tick handler or UART handler


    for embOSView was called without


    a call of

    OS_EnterInterrupt().



    so I have used

    static void _OS_SystemIrqhandler(void) {

    Source Code

    1. volatile unsigned int unPitCnt = (AT91C_BASE_PITC->PITC_PIVR >> (AT91C_PITC_PICNT));
    2. if ( unPitCnt ) { // new tick
    3. OS_EnterInterrupt();
    4. OS_TICK_Handle();
    5. OS_LeaveInterrupt();
    6. }
    7. }

    then
    OS_ERR_NOT_IN_ISR occured. Don't khow how to fix this !!


    Thanks for your support
    ~Ashok
  • Hello Ashok,

    it's not necessary to call OS_EnterInterrupt()/OS_LeaveInterrupt() in your interrupt routine because it is already called in the OS_irq_handler() function.

    Without more information it's hard to say what goes wrong.
    Could you please give us some more information?

    Which embOS version do you use?
    Which CPU/evalboard and start project do you use?
    Did you make any further modifications to RTOSInit.c?

    You can also contact our support directly, sounds like it would be something which we can solve very quickly.

    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 Til,

    my problem is OS_ERR_ILLEGAL_OUT_ISR while executing _OS_SystemIrqhandler.

    I'm using RTOSINIT_AT91SAM9G45.c

    embOS library file name: os5t_al__dp.a (don't know how to check the version name)

    board: ATMEL AT91SAM9G45

    I have attached RTOSINIT_AT91SAM9G45.c along with few other embOS files please check.



    Thanks,

    Ashok

    Files
    • embOS.zip

      (32.52 kB, downloaded 948 times, last: )
  • Hello Ashok,

    you made several changes to the RTOSInit.c.
    Could you please try it again with the original RTOSInit.c?
    You removed for example the initialization of the interrupt controller, maybe you initialize it somewhere else but I can't know without having the complete project.

    You could also set a breakpoint at address 0x18 (IRQ) and step through the disassembly, do you reach the OS_irq_handler() function?

    If you like you can send us your complete project and I will have a look in it.

    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 Til,



    I have checked AIC confugure in RTOSINIT.c file

    Source Code

    1. void _InitAIC(void) {
    2. int i;
    3. OS_ISR_HANDLER** papISR;
    4. AIC_IDCR = 0xFFFFFFFF; /* Disable all interrupts */
    5. AIC_ICCR = 0xFFFFFFFF; /* Clear all interrupts */
    6. AIC_FFDR = 0xFFFFFFFF; /* Reset fast forcings */
    7. AIC_SVR0 = (int) _DefaultFiqHandler; /* Dummy FIQ handler */
    8. AIC_SPU = (int) _SpuriousIrqHandler ; /* Dummy spurious handler */
    9. papISR = (OS_ISR_HANDLER**) AIC_SVR_BASE_ADDR;
    10. for (i = 1; i < NUM_INT_SOURCES; i++) { /* Initially set all sources */
    11. *(papISR + i) = &_DefaultIrqHandler; /* to dummy irq handler */
    12. }
    13. for (i = 0; i < NUM_INT_PRIORITIES; i++) {
    14. AIC_EOICR = 0; /* Reset interrupt controller */
    15. }
    16. #if DEBUG // For debugging activate AIC protected mode
    17. AIC_DCR |= 0x01; // Enable AIC protected mode
    18. #endif
    19. }
    Display All




    here is my code to Configure AIC handlers

    Source Code

    1. AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF;
    2. AT91C_BASE_AIC->AIC_SVR[0] = (unsigned int) defaultFiqHandler;
    3. for (i = 1; i < 31; i++) {
    4. AT91C_BASE_AIC->AIC_SVR[i] = (unsigned int) defaultIrqHandler;
    5. }
    6. AT91C_BASE_AIC->AIC_SPU = (unsigned int) defaultSpuriousHandler;
    7. // Unstack nested interrupts
    8. for (i = 0; i < 8 ; i++) {
    9. AT91C_BASE_AIC->AIC_EOICR = 0;
    10. }




    I'm getting interrupts from PIT, I mean PIT handler gets called

    Source Code

    1. static void _OS_SystemIrqhandler(void) {
    2. if (AT91C_BASE_PITC->PITC_PISR & (1uL << 0)) { /* Timer interupt pending? */
    3. Dummy = AT91C_BASE_PITC->PITC_PIVR;
    4. // OS_HandleTick(); //with active line getting OS_ERR_ILLEGAL_OUT_ISR
    5. piCount++;
    6. }
    7. }


    when I add OS_HandleTick(); PIT interrupt handler I get OS_Error OS_ERR_ILLEGAL_OUT_ISR.

    I'm sure AIC handlers are configured well. you mentioned OS_irq_handler() should get called but I can't see for which IRQ this irq hanlder should be assigned ?

    in my code I have never reached OS_irq_handler() !! Any direction ?



    Thanks,

    Ashok
  • Hi Ashok,

    in my code I have never reached OS_irq_handler() !! Any direction ?

    That's the problem ;-).

    you mentioned OS_irq_handler() should get called but I can't see for which IRQ this irq hanlder should be assigned ?

    I guess you replaced our startup code? Our startup code includes the vector table with the call to IRQ_Handler() at address 0x18.
    IRQ_Handler() is the embOS low level assembler interrupt handler which then calls OS_irq_handler().

    If you use your own startup code you maybe use another interrupt handler function, but this does not work with embOS.

    I suggest to start with our unmodified embOS start project and to not change files like the startup code or RTOSInit.c if it is not really necessary.

    If this does not solve your problem please send me your project.
    I already sent you an email, so you should have our embOS support email address.

    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.