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

Reading global buffer contents not always correct.

Hi all,

I have two NRF24LE1 devices, device_A for send data and device_B for receive data, the protocol data included in a 10-bytes length arrary(buffer).

In device_B 's codes, when received an RF frame, in RF_IRQ() of rf.c, it fisrt read the RF data and store them into Rx_buffer, then it set a global flag to 1 to indicate that new RF data has been received. In the meantime, the while loop in main.c check the flag whether equals to 1, if yes, then it will call RF_Handler() to process the RF data, such as light on one LED.

Now the problem is that while device_A periodically(1.5s interval each time) send RF frames, in most time the device_B can periodically light the LED, but not always. My colleagues and I have checked lots of factors and we are sure that 1)device_A can send frames correctly, we have one LED to indicate it; 2)device_B can receive the hardware level data correctly each time(in RF_IRQ()); 3)device_A and device_B are close to each other, about 1m without any walls;

We have another interesting founding that if we low-down the optimization level of Keil C51, the problem happened less than before, but still cannot eliminated(we have changed it to level-2, and to change to level-0 is not allowed cause of code size limitation). So, currently there are global variables: receive_rf_data_flag, and the Rx_buffer[10];

Could you please kindly give your ideas how to permanently eliminate this problem? Thanks in advance!

Best regards! Junma

  • Hi Junma,

    When compiled with optimization, the instructions are not exactly follow what you have in the code, so the debugger would not able to do break point as well as reading the variables value.

    My suggestion for you for debugging is:

    • Use UART to debug, writing out the value you receive, or at least log the value you receive on device_B to see if there is any packet missing.

    • Use a logic analyzer to log the LED blinking to see if there any event missing, packet not arrive, or re-transmission packet etc.

    • You can use shorter interval for testing, instead if 1.5 seconds you can use 150ms for example.

    • Do you use ACK ? it the ACK packet is not received and it's a retransmission from the TX the RX won't notify the application.

    • Have you tried to test with our SDK example ?

Related