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

Using C51 of nRF24LE1 to write 32-byte to its' L01-module, oscilloscope shows it is about 200us (means speed <1.2 Mbps) . How to modify C51-code to achieve 1.6 Mbps? ( = 2Mbps - preamble/crc/etc)

I use the following code to write 32-byte to L01-module. (The wireless-communication works successfully ).

The following (420us+200us), accompany only 32-byte wireless-transmission, which means the real-rate is only 412 Kbps.    How to make speed fast?

//-----------------//-----------------//-----------------
for( cnt=0; cnt<=Total; cnt+= 32 ) {
    read_image_info (  (org_addr+ cnt),  &buf32B[0]  );    //about 420us   // Master SPI,  config  1/4 * 16M
    LE1_SPI_Write_Buf (WR_TX_PLOAD, &buf32B[0], 32 );  // about 200us
}

//-----------------//-----------------//-----------------
void LE1_SPI_Write_Buf (unsigned char addr, unsigned char *Buf, unsigned char num)
{
    RFCSN = 0;
    SPI_RW(addr);
    while(num--) { SPI_RW(*Buf++); }
    RFCSN = 1;
}

unsigned char SPI_RW (unsigned char value)
{
    SPIRDAT = value;
    while(!(SPIRSTAT & 0x02));
    return SPIRDAT;
}

//-----------------//-----------------//-----------------
SPIMCON0 = 0x13;   //Master SPI [6:4],001,1/4 ckMCU; [3],0,MSBit first; [2:1],01-mode; [0],1,SPI master-EN

void read_image_info (uint32_t addr17bit,   uint8_t *ptr)
{
     uint8_t   i,   addr17pos;
     addr17pos = (addr17bit>>16) & 0x01 ;

     SPI_CSn = 0;
     IO_SPI_RW( 0x80 | addr17pos); //100_wr1rd0_000(imgPosition)_addr17pos
     IO_SPI_RW( addr17bit>>8 );
     IO_SPI_RW( addr17bit);
     for( i=0;  i<31;  i++)   *(ptr+i) =  IO_SPI_RW(0x55);
     SPI_CSn = 1;
}

uint8_t IO_SPI_RW (uint8_t value)
{
    SPIMDAT = value;
    while ( ! (SPIMSTAT & 0x02) );
    return SPIMDAT;   // Return data register
}

  • Hi

    I did some work on this many years ago, and was able to optimize the write speed to the radio quite significantly. 

    Attached you will find a small project with some modified read/write payload functions included. As you can see from the comments it should take about 78us to write a 32 byte payload from XDATA memory in the nRF24LE1:

    Quick shockburst.zip

    I also experimented with assembly code to get it even quicker, but for most applications I think the example above is sufficient, and easier to integrate. 

    Best regards
    Torbjørn

Related