This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Systick handler not getting triggered

Hi All,

I have configured systick timer to generate an interrupt every one millisecond,but when I am in the below function with readPbs()==8 the interrupt is not getting generated even though the NVIC_ST_CURRENT value changes.Could anyone suggest why is this happening in this manner and what can I do so that the interrupt gets generated as per timer even if waiting on an infinite loop?

void uncooperative()
{
while(true)
{
while (readPbs() == 8)
{
}
yield();
}
}

Regards,

Deepu Philip

  • Hi deepu,

    Please provide the code with which you configure the Systick and the interrupt

    Do you have any higher priority interrupt being generated? 
    Is it possible that readPbs() disables the interrupts?
    Did you check if the systick interrupt is working as intended without that while, instead with a simple, empty while(1)?
    Is void uncooperative() a handler by itself?

  • Hi Luis ,

    Systick configuration:

    NVIC_ST_CTRL_R = 0; // disable SysTick during setup
    NVIC_ST_RELOAD_R = 0x9C3F; // maximum reload value
    NVIC_ST_CURRENT_R = 0; // any write to current clears it
    NVIC_SYS_PRI3_R = NVIC_SYS_PRI3_R&0x00FFFFFF; // priority 0
    NVIC_ST_CTRL_R = 0x00000007;

    Systick Handler:

    void SysTick_Handler(void)
    {

    int k=0;
    while(k<MAX_TASKS)
    {
    if (tcb[k].state == STATE_DELAYED)
    {
    if(tcb[k].ticks > 0)
    {

    tcb[k].ticks--;
    }

    else
    {
    tcb[k].state = STATE_READY;
    }

    }
    k++;
    }

    }

    }

    readPbs() just reads the status of push buttons ie, which push button is pressed.

    I have a couple of tasks running and tasks need to be switched one to another.The handler is just used to  bring back  tasks from sleep based on the  the value in tcb[k].ticks.

    void uncooperative() is just another task(not a handler).I have checked with empty while(1) and it still not going to handler when in the loop.

    Is this anything to do with IPSR register ?

    Regards,

    Deepu Philip

  • Hi Deepy, thanks for the response back.


    Have you ever got systick working with a simple code?
    If not, try making a simple test code just for the systick.

    Also I am not sure if using NVIC_ST_CTRL_R = 0x00000007; is the best course.
    Since there's also the COUNT field that is read-only and writing to it could cause unpredictable results if I am not mistaken.
    So you should instead do NVIC_ST_CTRL_R |= 0x00000007;
    Same thing happens in NVIC_ST_CTRL_R = 0;

    Something similar in NVIC_SYS_PRI3_R = NVIC_SYS_PRI3_R&0x00FFFFFF;
    Unless you want to change the other 2 expections controlled by that register you should not alter the rest of the bits, also some bits there are labeled has read-only too. Simply NVIC_SYS_PRI3_R = NVIC_SYS_PRI3_R | 0xE0000000; or NVIC_SYS_PRI3_R |= 0xE0000000; should do to just alter the systick exception priority.

    Your use of just = instead of |= or &=~ could also be making problems in the rest of the registers... not all 32bits need to be altered most of the time.
  • Hello Deepu,

    Check the value of the SYSTICK Control register when the counter is counting? Also is the interrupt handler mapped in the Vector table?

    Regards
    Amit