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

nRF24LE1, example PRX in nRFgo SDK, why not volatile global array?

Hello everybody, I study transceiver nrf24LE1. I'm trying to understand example of PRX in nRFgo SDK (Enhanced_shockburst_examples):

/

    / Global variables
    uint8_t payload [3];
     
    // Radio interrupt
    NRF_ISR () // #define NRF_ISR () void nrf_isr (void) interrupt 8 // RF interrupt (0x4b)
    {
    ...
         // Read payload
    ...
           hal_nrf_read_rx_payload (payload);
    ...
    }

Please explain why uint8_t payload [3] is not declared as volatile ? Thank you so much!!!

Parents
  • Hi Artem,

    Could you explain a little bit more why you think volatile is needed ? My understanding is that we are not using the payload anywhere outside of the interrupt handler. hal_nrf_read_rx_payload () simply read the RX buffer and put into the payload array. We have no dependency on the payload value in main loop for example.

  • Thank you very much for your participation in my question. I thought that the payload [3] is a global variable that is changed in the interrupt handler, and is available in the main loop. And due to the fact that in the main loop is no reference to this variable, the optimizer will throw it. I thought that all these variables have to be volatile. If I add in the main loop to use (read) payload [3], should I declare it volatile? Thank you.

Reply
  • Thank you very much for your participation in my question. I thought that the payload [3] is a global variable that is changed in the interrupt handler, and is available in the main loop. And due to the fact that in the main loop is no reference to this variable, the optimizer will throw it. I thought that all these variables have to be volatile. If I add in the main loop to use (read) payload [3], should I declare it volatile? Thank you.

Children
No Data
Related