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

WRITE/READ COMMAND FOR NRF24L01 VIA SPI

Hi, i'm using the nrf24l01 with a zynq board to use it as radiocontrol; i'm trying to configure the nrf as receiver so that i'm able to send data from another nrf connected to an arduino. The first step i had to do, as i understood frome the datasheet, is being able to write and read register from nrf, so that i can configure nrf as receiver and also i can modify parameters for the communication (as bit rate, frequency,ecc). i tried to write the CF_REG with 00000011 (that are the setting for PRIM_RX and PWR_UP) using spi, and then reading the new content of the register. As i discovered i had to send the command and then the data i must overwrite, so i first sent 00100000 (that should be write register CF_REG), and then i sent 00000011, but it seems not to work. The first question i'd like to ask is if i have to send the 2 bytes with two different commands or if i can send a single command with a 2 bytes data (00100000-00000011 in this case).
The second question is if anyone already worked with zynq and is able to determine if i'm configuring properly the sdk. the code i wrote is below, thanks

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void write(XSpiPs *myinstanceptr){
u8 * commandptr;
u16 command = 0b0010001000000011;
commandptr = &command;
u8 * dataptr;
u8 data = 0b00000011;
dataptr = &data;
XSpiPs_SetSlaveSelect(myinstanceptr,0);
(myinstanceptr)->IsBusy=0x00000000;
XSpiPs_Transfer(myinstanceptr,commandptr,NULL,2);
(myinstanceptr)->IsBusy=0x00000000;
//XSpiPs_Transfer(myinstanceptr,dataptr,NULL,1);
//(myinstanceptr)->IsBusy=0x00000000;
XSpiPs_SetSlaveSelect(myinstanceptr,0X0F);
}
u8 read(XSpiPs *myinstanceptr){
u8 * commandptr;
u8 command = 0x00;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX