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

spi_event_handler can not be triggered after button is pushed.

hi

I write a function getT() to read spi thermalcouple chip. if the function getT() is called in main() function, it will work correctly. Hence, I think that getT() is correct essentially.

if the function getT() is called when BSP_EVENT_KEY4 is triggered(in function bsp_event_handler), the function getT() does not work correclty.

Trace the codes, I find the function spi_event_handler() does not be called and causes err_code = NRF_ERROR_BUSY in function nrf_drv_spi_xfer.

I.E. the funtion spi_event_handler() will not be called after the funtion bsp_event_handler() is called.

The following is part of my codes:

int main(void)
{ ....
  spi_config();
  getT();
  ....
}

In above code, the function getT() in the main() block is work correctly.

static void bsp_event_handler(bsp_event_t event)
{ .....
  switch (event) {
     ....
     case BSP_EVENT_KEY_4:
     getT();
  }
  ....
}

In above code, the function getT() can not work correctly when it is put in the bsp_event_handler block.(The spi_event_handler does not be called)

How can I fixed this issue?

Thank you for your help. Best Wishes

Parents
  • The fact that getT() works in main, but not when you call it from within a handler (interrupt) points to a problem with interrupt priorities or nesting?

  • The interrupt and event handling states/levels are commonly not re-entrant, or may not allow a given interrupt or event to be processed from an interrupt or event handler.

    For example, if getT() is doing something that causes an event to be triggered, it may not be possible to handle the (getT()) generated event from an event handler.

    Your description of your issue seems to suggest something like that.

    Can you post the source for getT()?

    If you can't post the source for getT() here in the forum because of confidentiality, you can open a service ticket. Information provided in service tickets is only seen by Nordic employees and is protected from disclosure to any customer other than your company.

Reply
  • The interrupt and event handling states/levels are commonly not re-entrant, or may not allow a given interrupt or event to be processed from an interrupt or event handler.

    For example, if getT() is doing something that causes an event to be triggered, it may not be possible to handle the (getT()) generated event from an event handler.

    Your description of your issue seems to suggest something like that.

    Can you post the source for getT()?

    If you can't post the source for getT() here in the forum because of confidentiality, you can open a service ticket. Information provided in service tickets is only seen by Nordic employees and is protected from disclosure to any customer other than your company.

Children
No Data
Related