software SPI and Nrf24l01

I need some help with some code (Thanks Leon). I need to read values out of the nrf24l01 so i can see what data was recieved.

if (SPI_IRQ == 0)

{

SPI_CSN = 0; //Tell The NRF24 to start listening.

SPI_CE = 0; //Hold the data line low to start piping out the information

spi_Send_Read(xxxx); //Send the instruction

data = spi_Send_Read(xxxxx); //Send the data

SPI_CE = 1;

}

Im just not sure about the xxx’s in the above code. I know you need to send a command with the register name in the first line.

Any help would great!

The first xxxx code would just be the register number, as you mentioned. The second one is simply one or more dummy bytes to allow you to get the value of the register. The TX and the pipe 0 and pipe 1 RX addresses require five dummy bytes to read all of the data out, but all of the other addresses only require one dummy byte. The return of the command byte is the STATUS register.

So would the first line be

spi_Send_Read(0x61);

0x61 being the R_RX_Payload command.

And the second one being:

spi_Send_Read(0x34); //Dummy Read

spi_Send_Read(0x33); //Dummy Read

spi_Send_Read(0x32); //Dummy Read

spi_Send_Read(0x31); //Dummy Read

On another note I thought you needed the Command And the address of the register int the first spi command line?

Here is what I got for my Read data function

//Read RX payload

SPI_CSN = 0;

data = spi_Send_Read(0x61); //This is my data

for (j = 0; j < 4; j++)

{

buffer[j] = spi_Send_Read(0);

}

SPI_CSN = 1;

printf(data);

Right Now I have a 4 byte payload If my code is correct then there is something wrong because im only recieving gibberish on the other end. And if my code is correct I think i have a timing problem. I have an 18F452 running with the standard crystal on the P40 development board and my transmitter is the 16F88 with internal oscillator. Any Ideas on how I setup / correct the timing problems provided the code above looks correct ???

Also I forgot my TX data payload. Here is what im using for my TX payload

spi_Send_Read(0xA0);

spi_Send_Read(‘b’);

If that helps.

Fixed it my printf statement was the entire problem the format should be

printf(“%c”, sendVariable);

One last question any advice on setting up proper timing on the chip as I have a 18F452 running at a different speed then the 16F88?