Need assistance Systick handler not getting called

-1

I am trying to use the systick handler in MSP432 controller for context switching but the systick handler is never called. I'm not sure what I doing wrong I set the interrupt priority to the highest and set PendSV to the lowest. I do disable interrupts but always re enable them so I do not think that is the issue.

void OS_onStartup(void){
    SystemCoreClockUpdate();
    SysTick_Config(SystemCoreClock / 10000);
    NVIC_SetPriority(SysTick_IRQn, 0U);
    //*(uint32_t volatile *)0x0000003C  |= 0U;
}

void OS_init(void){
    // set the penSV interrupt priority to the lowest level
    *(uint32_t volatile *)0x00000038  |= (0xFFU << 16);
 }

 void SysTick_Handler(void) {
     ++l_tickCtr;
     __disable_interrupts(); // @suppress("Function cannot be resolved")
     OS_sched();
     __enable_interrupts(); // @suppress("Function cannot be resolved")
  }

int main() {

    MSP_start();
    OS_init();
    /* fabricate Cortex-M ISR stack frame for blinky1 */
    OSThread_start(&blinky1,
               &main_blinky1,
               stack_blinky1, sizeof(stack_blinky1));

    /* fabricate Cortex-M ISR stack frame for blinky2 */
    OSThread_start(&blinky2,
               &main_blinky2,
               stack_blinky2, sizeof(stack_blinky2));

    OSThread_start(&blinky3,
                   &main_blinky3,
                   stack_blinky3, sizeof(stack_blinky3));

    //transfer control to the RTOS to run threads

    OS_run();

   //return 0;
   }

void OS_run(){
    OS_sched();
    //to start interrupts
    __disable_interrupts(); // @suppress("Function cannot be resolved")
    OS_onStartup();
    __enable_interrupts(); // @suppress("Function cannot be resolved")
   //code should not execute
   //while(1){}
 }
c
arm
embedded
msp430
rtos
asked on Stack Overflow Feb 3, 2021 by Mperez • edited Feb 3, 2021 by Mperez

1 Answer

1

This:

    // set the penSV interrupt priority to the lowest level
    *(uint32_t volatile *)0x00000038  |= (0xFFU << 16);

does not do what the comment says. 0x00000038 is the default address of the PendSV vector and on MSP432 is a ROM address. The PendSV priority is set using the System Handler Priority Register 3 register which is at 0xE000ED20:

enter image description here

You could write the register directly, but it is far simpler to use the CMSIS NVIC_SetPriority():

NVIC_SetPriority( PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1 ) ;

Or

NVIC_SetPriority( PendSV_IRQn, 0xff ) ;

The first is generic and will work across different Cortex-M implementations.

answered on Stack Overflow Feb 3, 2021 by Clifford • edited Feb 3, 2021 by Clifford

User contributions licensed under CC BY-SA 3.0