This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52832 app_timer bug?

SDK version :15.2

question; when i use app_timer , i got interrupt which is not i wanted.

i creat and start  timer :

app_timer_create(&m_timer,APP_TIMER_MODE_REPEATED,sec_timer_hook);:  

m_sec_context = 0xa5;
app_timer_start(m_timer,APP_TIMER_TICKS(20),&m_sec_context);  

and hook like:

void sec_timer_hook(void *p_context)
{
if(*(uint32_t*)p_context != 0xa5)
{
     led_toggle();
}
}

many times led toggled, is that means some interrupt is not i wanted ,is that a app timer bug?

Parents
  • Hi,

    Please post a minimal working example of this issue. From what you posted, it is not clear how m_sec_context is declared. What data type is m_sec_context? Where is it declared? Is it static?

    My guess is that m_sec_context was declared in a function (i.e. not in main()), which means that it lives on the stack. When that function returns, the variable is gone, and the memory address to which &m_sec_context points is no longer valid. Then, when you check the memory to which p_context points, it is most likely garbage. To check if this is the case, you can declare m_sec_context as static and see if the problem goes away.

    I doubt there is an issue with app_timer here.

Reply
  • Hi,

    Please post a minimal working example of this issue. From what you posted, it is not clear how m_sec_context is declared. What data type is m_sec_context? Where is it declared? Is it static?

    My guess is that m_sec_context was declared in a function (i.e. not in main()), which means that it lives on the stack. When that function returns, the variable is gone, and the memory address to which &m_sec_context points is no longer valid. Then, when you check the memory to which p_context points, it is most likely garbage. To check if this is the case, you can declare m_sec_context as static and see if the problem goes away.

    I doubt there is an issue with app_timer here.

Children
Related