- Posts: 4402
Detecting the NRF24L01
- PhracturedBlue
- Topic Author
- Offline
Less
More
27 Mar 2014 12:19 #21881
by PhracturedBlue
Detecting the NRF24L01 was created by PhracturedBlue
I've recently added code todetct which modules are present in the transmitter. This is done during the reset procedure by querying registers after reset for known reset state. However the NRF24L01 has no software reset. This means that the module is detected on power-up, but if there is a reboot for any reason, or you toggle power too quickly, the module will not be detected.
I am not very familiar with this chip, so I'm hoping some of the experts here can come up with a more reliable signature for the NRF24L01.
I am not very familiar with this chip, so I'm hoping some of the experts here can come up with a more reliable signature for the NRF24L01.
Please Log in or Create an account to join the conversation.
- hexfet
- Offline
Less
More
- Posts: 1891
27 Mar 2014 12:37 - 27 Mar 2014 12:42 #21882
by hexfet
Replied by hexfet on topic Detecting the NRF24L01
Can't claim expert status since I've only used this chip on the one protocol, but I'll start things off. When I toyed with this before I used this:
u8 NRF24L01_Reset()
{
// chip has no software reset - write default value to config. Also puts chip in power down state
NRF24L01_WriteReg(NRF24L01_00_CONFIG, (1 << NRF24L01_00_EN_CRC));
// read back as test of interface
return NRF24L01_ReadReg(NRF24L01_00_CONFIG) == (1 << NRF24L01_00_EN_CRC);
}
Last edit: 27 Mar 2014 12:42 by hexfet.
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Topic Author
- Offline
Less
More
- Posts: 4402
27 Mar 2014 15:47 - 27 Mar 2014 15:48 #21885
by PhracturedBlue
Replied by PhracturedBlue on topic Detecting the NRF24L01
Thanks,
I guess I forgot the 2nd part. Ideally the return would be unique to only this chip. Writing a value and reading it back will not uniquely identify a chip generally, though it depends on the address.
A quick check shows that CC2500, A7105 and CYRF6936 will all give an identical response when writing (virtually) any value to 0x00
I guess I forgot the 2nd part. Ideally the return would be unique to only this chip. Writing a value and reading it back will not uniquely identify a chip generally, though it depends on the address.
A quick check shows that CC2500, A7105 and CYRF6936 will all give an identical response when writing (virtually) any value to 0x00
Last edit: 27 Mar 2014 15:48 by PhracturedBlue.
Please Log in or Create an account to join the conversation.
- victzh
- Offline
Less
More
- Posts: 1386
27 Mar 2014 16:15 #21887
by victzh
Replied by victzh on topic Detecting the NRF24L01
Yes, it's a bit unfriendly for identification. May be there are registers which has unique read-only bits and will ignore writing to them? I will take a look at the datasheet.
Please Log in or Create an account to join the conversation.
- victzh
- Offline
Less
More
- Posts: 1386
27 Mar 2014 16:26 #21888
by victzh
Replied by victzh on topic Detecting the NRF24L01
How about FLUSH_TX, FLUSH_RX and reading STATUS with NOP and with regular read from STATUS register? They should match, and low nibble should read as 0xE.
Also, if you set one of the bits in EN_AA (auto-acknowledgement), EN_CRC bit in CONFIG is "forced high", so it should "resist" writing to.
I am far from my nRF24L01, so these are only results of theoretical research of datasheet plus some memories from watching SPI traces.
Also, if you set one of the bits in EN_AA (auto-acknowledgement), EN_CRC bit in CONFIG is "forced high", so it should "resist" writing to.
I am far from my nRF24L01, so these are only results of theoretical research of datasheet plus some memories from watching SPI traces.
Please Log in or Create an account to join the conversation.
- hexfet
- Offline
Less
More
- Posts: 1891
27 Mar 2014 20:17 #21895
by hexfet
Replied by hexfet on topic Detecting the NRF24L01
Yes, that code was for checking a known nRF was responding. I don't know much about the other radio chips so don't know how to distinguish among them.
The Beken/Hope clones of the nRF have a device ID in the extended register set. Haven't seen anything similar for the nRF itself.
The Beken/Hope clones of the nRF have a device ID in the extended register set. Haven't seen anything similar for the nRF itself.
Please Log in or Create an account to join the conversation.
- btoschi
- Offline
Less
More
- Posts: 151
27 Mar 2014 20:37 #21896
by btoschi
Replied by btoschi on topic Detecting the NRF24L01
nRF will always return the content of the status register when sending a command, regardless which command you send:
"The STATUS register is serially shifted out on the MISO pin simultaneously to the SPI command word shifting to the MOSI pin"
Datasheet mentions that sending 8 '1's = 0xff is a NOP, which is to be used to read only status register back.
Reset value of status register is 0xE (= RX FiFo Empty).
Programming a register and expecting the very same value back is not such a good proof for a specific device, this even works on most of the registers of my good ol' VIC (C64 Graphics chip)
"The STATUS register is serially shifted out on the MISO pin simultaneously to the SPI command word shifting to the MOSI pin"
Datasheet mentions that sending 8 '1's = 0xff is a NOP, which is to be used to read only status register back.
Reset value of status register is 0xE (= RX FiFo Empty).
Programming a register and expecting the very same value back is not such a good proof for a specific device, this even works on most of the registers of my good ol' VIC (C64 Graphics chip)
Please Log in or Create an account to join the conversation.
- victzh
- Offline
Less
More
- Posts: 1386
27 Mar 2014 21:16 #21899
by victzh
Replied by victzh on topic Detecting the NRF24L01
The point of my method is interdependence of the registers - you write something into one register and expect some bits in another. It works only if the chip does exactly the same procedures, especially WRT to (hypothetical, not tested but deduced from datasheet) write resistance of a EN_CRC bit. I need to verify this, which I'll do in several hours.
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Topic Author
- Offline
Less
More
- Posts: 4402
31 Mar 2014 17:44 #21971
by PhracturedBlue
Replied by PhracturedBlue on topic Detecting the NRF24L01
I tried victzh's method, and it seems to work fine, so I'll replace the rather crude code with his.
Thanks.
If anyone has further improvements, just let me know.
Thanks.
If anyone has further improvements, just let me know.
Please Log in or Create an account to join the conversation.
Time to create page: 0.046 seconds
- Home
- Forum
- Development
- Development
- Detecting the NRF24L01