Fast switching RX/TX mode and crash on nRF24LE1

Questions for programming 8051 microcontrollers in C or assembly using SDCC

Fast switching RX/TX mode and crash on nRF24LE1

Postby lorenberg » Tue Mar 18, 2014 12:58 pm

Dear all,

I'm developing a communication protocols on nRF24LE1, and I'm stuck on an annoying problem.

I'm assuming 2 devices that talk to each other, each one of them sending a packet toward the other

at different rates (1 packet every second, every 100 milliseconds and every 10 milliseconds).

When the traffic load increases, it happens that sometimes one of the 2 devices crashes.

I believe this is due to an interrupt coming when the device is in the "RX Settling" or "TX settling" states,

thus making it impossible for it to receive a new packet.

I tried everything, disabling interrupts, using control variables, and anything else that came to my mind, but until now

I was not able to fix the bug. I thought on using atomic variables, but apparently they are not feasible for the 8051.

Can someone give me an hint?

Thanks!
lorenberg
 
Posts: 7
Joined: Mon Nov 25, 2013 10:26 am

Re: Fast switching RX/TX mode and crash on nRF24LE1

Postby brennen » Wed Mar 19, 2014 12:02 pm

So I'm not entirely sure if it's the same problem as you're having, but when I was initially bringing up my mesh protocol, I found one place where the radio could get stuck in a state and never come out. What would happen is this:
1) Receive RX packet
2) Set device to TX just afterward
3) Take interrupt for RX
4) No longer able to send packet

So essentially all I did was clear all interrupts immediately after I set the device to a TX (*before* actually sending any packets), and that seemed to fix things. I'm not sure if this will help you out, but it's at least an idea.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: Fast switching RX/TX mode and crash on nRF24LE1

Postby lorenberg » Wed Mar 19, 2014 5:01 pm

Hi Brennen,

thanks for you reply.

Actually, I tried almost everything, including the clearing of all interrupts just after entering in TX mode.

I also removed the Timer0 I was using for measuring events, moving to delay_us instead, just to avoid timer interrupts.
Nothing to do, it is still crashing at random times.

Just to be sure, what should I write to clear ALL possible interrupts? What I did so far is setting

IEN0 = 0x00;
IEN1 = 0x00;

Is it enough? Or I may be missing something else?

And, the TX is managed without triggering an interrupt. Now, if I wrote everything correctly, the only source of interrupt is a packets reception. And when the RX interrupt is triggered, the first thing I do is clearing all the interrupts as well.

This is really driving me crazy, I have no idea what else I can try....

Thanks again!
lorenberg
 
Posts: 7
Joined: Mon Nov 25, 2013 10:26 am

Re: Fast switching RX/TX mode and crash on nRF24LE1

Postby brennen » Wed Mar 19, 2014 5:27 pm

No I mean the RF interrupts in the STATUS register (TX_DS, RX_DR, and MAX_RT). If you're using my SDK, you can call rf_irq_clear_all().
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: Fast switching RX/TX mode and crash on nRF24LE1

Postby lorenberg » Thu Mar 20, 2014 9:22 am

No, I'm using the uVision HAL with keil compiler.

But in any case, I was actually clearing every possible interrupt. And still, sometimes the chip crashes.

At this point, I fear that they cannot work when the rate of packet generation is 10 milliseconds.

I cannot see another way to avoid the concurrent access to the critical section.

Actually, the only source of interrupt is the RX_DR, which is cleared when in PTX mode.

I also manage the transmission of a packet without TX_DS interrupt (I emtpy the sending queue by hand instead of calling
the interrupt), but still, it crashes.

I cannot figure out a solution.

If anything else come to your mind, just tell me, otherwise I really have no other idea :)

Thanks again
lorenberg
 
Posts: 7
Joined: Mon Nov 25, 2013 10:26 am

Re: Fast switching RX/TX mode and crash on nRF24LE1

Postby lorenberg » Thu Mar 20, 2014 10:54 am

YEEEEEE!!

In the end, I was finally able to make it work......

Essentially, what I did is the following

- not using timer0, timer1 and so on but only delay_ms and delay_us (I will later check if timers can be used, though)
- disabling RF interrupts as soon as the chip is entering in TX mode
- checking if there is an rx interrupt (RX_DR) before switching to TX mode

- setting CE = 0 AS FIRST INSTRUCTION WHEN RX_DR IS FALSE.


Actually, this made it working.
lorenberg
 
Posts: 7
Joined: Mon Nov 25, 2013 10:26 am

Re: Fast switching RX/TX mode and crash on nRF24LE1

Postby brennen » Thu Mar 20, 2014 12:21 pm

Judging by your description, you found the exact same problem as me. Essentially, you would get an RX_DR interrupt around the same time you switch into TX mode, and then would try to send a packet, which crashes the radio hardware. Congrats on fixing your problem! :)
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm


Return to 8051 Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron