My problem now is that SPI.transfer only returns 4 bit instead of a whole byte. Could this be because of the nRF chip? Or is my code wrong. I deliberately set the SPI clock speed very low because I thought it might be the issue, but it wasn't.
The documentation says the nRF chip gives its status register over SPI when CSNpin shifts from high to low. Is the arduino too slow to catch all of the status bits?
The address of the status register is 0x00, the byte I want to write is 0b01110010.
My main issue is still the 4 bit return from the chip. Is there anything I'm doing wrong?
1. Are you getting from the Slave what you are expecting? 2. I am not used to emply SPI.beginTransfer() and SPI.end() codes. 3. SS, MOSI, MISO, SCK (the four SPI Signals) are mapped to DPin-10 11, 12, 13 when SPI.h Library is included in the sketch. That's why, I prefer to use the symbolic name SS which will be be connected with the CS/-pin of Slave.
4. Your sketch looked alright and yet it did not appear to me as logical.
1. With your sketch I am getting what I am expecting. 0x00 is the address of the status register and the byte 0x72 is what I want to write to it. Then it should continue to only return the written byte.
2. The SPI.beginTransfer code wasn't emty but with my settings in it. SPI.end() is empty even in the documentation.
3. That makes sense, yeah.
4. That's because it isn't logical. At the moment I just wanted to establish that the nano and the nRF chip yould communicate over SPI as expected. It didn't so I threw everything at it what I found.
Thank you for your help. I think I can figure it out now.
But you are getting : 0x08 or 0x0E! Whre is the 0x72?
In fact, your sketch of Post-1 was working except that the leading four zeros were not being shown on the Serial Monitor; as a result, you saw only four bits.
I tried again with a different command word while in the process of writing the reply, which I forgot to mention. With the different command word I am getting reply 0x72. My fault.
Yes, it might have been just the command word which was wrong. Also, not using SPI.end() and SPI,beginTransmission(mySettings) is a huge improvement for my code to use.