Tail Chaining PendSV

201 Views Asked by At

I am creating an RTOS kernel using MSP432 Arm controller. I am using PendSV for context switching. The issue is that when the systick handler sets PendSV handler but it is never called. I have the Systick handler at priority 0 and PendSV at priority 15. I am not sure what is going wrong but I have tried to minimize the program but this has not help. Any advice would help, thank you.

void SysTick_Handler(void) {
   OS_tick();

   __disable_interrupts(); // @suppress("Function cannot be resolved")
   OS_sched();
   __enable_interrupts(); // @suppress("Function cannot be resolved")
 }


void OS_init(void *stkSto, uint32_t stkSize){
   // set the penSV interrupt priority to the lowest level
   NVIC_SetPriority( PendSV_IRQn, 0xFF) ; // @suppress("Invalid arguments")


   OSThread_start(&idleThread,
               &main_idleThread,
               stkSto,stkSize);

 }

 void OS_sched(void){

    if(OS_readySet == 0U){ // idle condition
        OS_currIdx = 0U; // set oscurridc to idle thread
    }
    else{
        // if else we have threads to run need ot do in round robin
        do{
           ++OS_currIdx;
         if(OS_currIdx == OS_ThreadNum){
            OS_currIdx = 1U;
          }
       } while((OS_readySet & (1U << (OS_currIdx - 1U))) == 0U);
    }
    OS_next = OS_thread[OS_currIdx];

    if(OS_next != OS_curr){

       // Pend a PendSV exception using by writing 1 to PENDSVSET at bit 28
       *(uint32_t volatile *)0xE000ED04 = (0x1 << 28);

        }

     }


void PendSV_Handler(void)
{
    PendSV_HandlerAsm();
}
0

There are 0 best solutions below