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

nrf24L01+ not all packages sent or received?

Hi,

Im trying to send 20 packages of 30bytes each as fast as possible, so I created the following loop:

for( pack=0; pack<20; pack++) { w_tx_payload_noack(30, MegaBuffer[pointerOUT]); msprf24_activate_tx(); //__delay_cycles(5000); }

On the receiving side I get only 6 packets. If I decrease number to 10 packets then I receive only 3.

Im sure there should be a logical explanation. I tried to add a delay into the loop it didnt help. Here are the functions used:

void msprf24_activate_tx() { char c; msprf24_standby(); // Cancel any outstanding TX interrupt w_reg(RF24_STATUS, RF24_TX_DS|RF24_MAX_RT); c = r_reg(RF24_STATUS); // Pulse CE for 10us to activate PTX pulse_ce(); }

void pulse_ce() { CE_HIGH(); __delay_cycles(CE_HIGH_TIME); CE_LOW(); }

Any idea on where Im misusing the device?

Thanks, Sergey

  • Hi Mike,

    Ive adjusted the code to check for space in TX FIFO:

    msprf24_standby(); int pack=0; int cnt = 10;

    		for( pack=0; pack<100; pack++)
    		{
    			while((r_reg(RF24_FIFO_STATUS) & RF24_FIFO_FULL));
    			w_tx_payload_noack(30, beacon_buf);
    			pulse_ce();
    			//__delay_cycles(1800);
    			//msprf24_activate_tx();
    		}
    

    Unfortunately it doesnt help anyways.

    Here is the standby function:

    // Enable Standby-I, 26uA power draw void msprf24_standby() { unsigned char state = msprf24_current_state(); if (state == RF24_STATE_NOTPRESENT || state == RF24_STATE_STANDBY_I) return; CE_LOW(); msprf24_set_config(RF24_PWR_UP); // PWR_UP=1, PRIM_RX=0 if (state == RF24_STATE_POWERDOWN) // If we're powering up from deep powerdown... __delay_cycles(DELAY_CYCLES_5MS); // Then wait 5ms for the crystal oscillator to spin up. }

  • when you say it doesn't help - before you got 3 out of 10 packets and now? does your transmit code complete? i.e do you exit your loop (are all the packets sent?) at what SPI speed does it now break? as a side note, in your current code you will not transmit the last two packets (I don't believe the chip counts the pulse_ce's, so when it finishes the loop, the fifo will have two messages in it and they won't get transmitted.) Out of a hundred, you have to expect several lost packets

    mike

Related