I have two STM8s105 MCUs and two NRF24L01+ modules. Set one as transmitter:
CONFIG: 0x3A
EN_AA: 0x00
EN_RXADDR: 0x03
SETUP_AW: 0x03
SETUP_RETR: 0x00
RF_CH: 0x00
RF_SETUP: 0x07
STATUS: 0x2E
OBSERVE_TX: 0x00
CD: 0x00
RX_ADDR_P0: 0xCC 0xCC 0xCC 0xCC 0xCC
RX_ADDR_P1: 0xCC 0xCC 0xCC 0xFF 0xFF
RX_ADDR_P2: 0xC3
RX_ADDR_P3: 0xC4
RX_ADDR_P4: 0xC5
RX_ADDR_P5: 0xC6
TX_ADDR: 0xCC 0xCC 0xCC 0xCC 0xCC
RX_PW_P0: 0x20
RX_PW_P1: 0x20
RX_PW_P2: 0x00
RX_PW_P3: 0x00
RX_PW_P4: 0x00
RX_PW_P5: 0x00
FIFO_STATUS: 0x11
DYNPD: 0x00
FEATURE: 0x00
NRF24L01 Send Data:
0x20 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F
0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F
One as receiver with 8 bits CRC enabled and ESB disabled:
CONFIG: 0x3B
EN_AA: 0x00
EN_RXADDR: 0x03
SETUP_AW: 0x03
SETUP_RETR: 0x00
RF_CH: 0x00
RF_SETUP: 0x07
STATUS: 0x0E
OBSERVE_TX: 0x00
CD: 0x00
RX_ADDR_P0: 0xCC 0xCC 0xCC 0xCC 0xCC
RX_ADDR_P1: 0xCC 0xCC 0xCC 0xFF 0xFF
RX_ADDR_P2: 0xC3
RX_ADDR_P3: 0xC4
RX_ADDR_P4: 0xC5
RX_ADDR_P5: 0xC6
TX_ADDR: 0xE7 0xE7 0xE7 0xE7 0xE7
RX_PW_P0: 0x20
RX_PW_P1: 0x20
RX_PW_P2: 0x00
RX_PW_P3: 0x00
RX_PW_P4: 0x00
RX_PW_P5: 0x00
FIFO_STATUS: 0x11
DYNPD: 0x00
FEATURE: 0x00
The receiver cannot receive any packet.
But when the CRC disabled, it works fine except that the receiver gets many noise(not sent by transmitter, because the receiver get those packets even the transmitter powered off) packets:
CONFIG: 0x33
EN_AA: 0x00
EN_RXADDR: 0x03
SETUP_AW: 0x03
SETUP_RETR: 0x00
RF_CH: 0x00
RF_SETUP: 0x07
STATUS: 0x02
OBSERVE_TX: 0x00
CD: 0x01
RX_ADDR_P0: 0xCC 0xCC 0xCC 0xCC 0xCC
RX_ADDR_P1: 0xCC 0xCC 0xCC 0xFF 0xFF
RX_ADDR_P2: 0xC3
RX_ADDR_P3: 0xC4
RX_ADDR_P4: 0xC5
RX_ADDR_P5: 0xC6
TX_ADDR: 0xE7 0xE7 0xE7 0xE7 0xE7
RX_PW_P0: 0x20
RX_PW_P1: 0x20
RX_PW_P2: 0x00
RX_PW_P3: 0x00
RX_PW_P4: 0x00
RX_PW_P5: 0x00
FIFO_STATUS: 0x10
DYNPD: 0x00
FEATURE: 0x00
NRF24L01 Status: 0x0E
NRF24L01 Data Received:
0x20 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F
0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F
Please help me, thanks!
BTW, I have a STC89C52 MCU board with integrated NRF24L01+ module. This board(CRC enabled) can receive the packet without any problem. So, I'm sure the problem is on the receiver side.
BTW 2, I use sdcc 3.4.0, stm8flash and STM8S_StdPeriph_Driver
Update: I modified my transmitter code with ESB(dynamic payload length enabled) and 8 bits CRC enabled, receiver with cdc disabled and always read 32 bytes from RX FIFO. Both modules use the default address: 0xE7E7E7E7E7. I got the following data when transmitter sent 3 bytes data: 0x00 0x01 0x02
0x0F 0x00 0x00 0x81 0x7D 0x3E 0xB3 0x25
0xF8 0x6A 0xBA 0xAA 0xD0 0xAD 0x5A 0xDA
0xA9 0x35 0x28 0x29 0x41 0x6E 0xED 0xD4
0xA2 0x29 0x42 0x93 0x42 0xAD 0x55 0x56
According to the spec, only the head 9 bits + 3 bytes data + 1 byte CRC are valid, so I parsed the received data manually, and got the following results:
Payload Length = 3
PID = 3
NO_ACK = 0
Data[0] = 0x00
Data[1] = 0x01
Data[2] = 0x02
CRC = 0xFA
The spec also says:
The CRC is the mandatory error detection mechanism in the packet. It is either 1 or 2 bytes and
is calcu- lated over the address, Packet Control Field and Payload.
The polynomial for 1 byte CRC is X8 + X2 + X + 1. Initial value 0xFF.
The polynomial for 2 byte CRC is X16+ X12 + X5 + 1. Initial value 0xFFFF.
Is the CRC right?
Update2: I used the STC89C52 board to send the same data and receiver got this:
0x0F 0x00 0x00 0x81 0x7D 0x3A 0x44 0xC7
0x54 0x01 0x6A 0xC9 0x74 0x8B 0x5B 0x2B
0x5D 0x4A 0xE5 0xAD 0x65 0x43 0xD5 0x95
0x66 0x69 0x6C 0xD2 0xA9 0x8D 0xAA 0xAD
This means the transmitter is OK because the STC89C52 works fine and data has no difference.