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

nrf24L01+ auto ack only works 3 times

I'm having some issues getting the auto ACK to work properly. I am only receiving auto ACK messages on the first 3 received packages, after which the receiver stops replying. Re-initializing has no effect, only a power cycle works, after which I again only get 3 ACK replies. I'm not using ACK payloads, so I don't see why there's a limit on 3 ACK messages. I'm kind of stuck here.

This is the configuration for the receiver:

//Disable RF
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, (GPIO_PinState)0);

//Setup address length
NRF24L01PWriteRegister(SETUP_AW, 0x03); //5 bytes

//Use the same address on the RX device as the TX device
NRF24L01WriteBuffer(RX_ADDR_P0, TX_ADDRESS, TX_ADR_LENGTH);

//Enable Auto.Ack:Pipe0
NRF24L01PWriteRegister(EN_AA, 0x01);
//NRF24L01PWriteRegister(EN_AA, 0x00);

//Enable Pipe0
NRF24L01PWriteRegister(EN_RXADDR, 0x01);

//Select radio channel
NRF24L01PWriteRegister(RF_CH, CHANNEL);

//Select same RX payload width as TX Payload width
NRF24L01PWriteRegister(RX_PW_P0, TX_PLOAD_WIDTH);

//TX_PWR:0dBm, Datarate:2Mbps, LNA:HCURR
NRF24L01PWriteRegister(RF_SETUP, 0x0F);

//Set PWR_UP bit, enable CRC(2 bytes) & Prim:RX. RX_DR enabled..
NRF24L01PWriteRegister(CONFIG, 0x0F);

//Make sure Dynamic Payload Length is disabled
NRF24L01PWriteRegister(FEATURE, 0x00);

//Enable RF
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, (GPIO_PinState)1);

And this is the configuration for the transmitter:

//Setup address length
NRF24L01PWriteRegister(SETUP_AW, 0x03); //5 bytes

//Writes TX_Address to nRF24L01
NRF24L01WriteBuffer(TX_ADDR, TX_ADDRESS, TX_ADR_LENGTH);

//RX_Addr0 same as TX_Adr for Auto.Ack
NRF24L01WriteBuffer(RX_ADDR_P0, TX_ADDRESS, TX_ADR_LENGTH);

//Writes data to TX payload
NRF24L01WriteBuffer(WR_TX_PLOAD, TX_PAYLOAD, TX_PLOAD_WIDTH);

//Enable Auto.Ack:Pipe0
NRF24L01PWriteRegister(EN_AA, 0x01);

//Enable Pipe0
NRF24L01PWriteRegister(EN_RXADDR, 0x01);

//500µs + 86µs, 10 retransmissions
NRF24L01PWriteRegister(SETUP_RETR, 0x1A);

//Select RF channel
NRF24L01PWriteRegister(RF_CH, CHANNEL);

//TX_PWR:0dBm, Datarate:2Mbps, LNA:HCURR
NRF24L01PWriteRegister(RF_SETUP, 0x0F);

//Set PWR_UP bit, enable CRC(2 bytes) & Prim:TX. MAX_RT & TX_DS enabled
NRF24L01PWriteRegister(CONFIG, 0x0E);

The receiving IRQ:

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)

uint8_t rx_pw;

__disable_irq();

switch(GPIO_Pin)
{
	case GPIO_PIN_1:
	{
		gIRQStatus = NRF24L01PReadRegister(STATUS);
		
		if(gIRQStatus & RX_DR)  //In RX mode, check for data received
		{
			//Data received, so find out which datapipe the data was received on:
			
			//Shift bits in status byte one bit to LSB and mask 'Data Pipe Number'
			gIRQStatus = (0x07 & (gIRQStatus > 1)); 
			
			//Read current RX_PW_Pn register, where Pn is the pipe the data was received on.
			rx_pw = NRF24L01PReadRegister(RX_PW_P0 + gIRQStatus); 
			
			//Data from RX Payload register is now copied to SPI_Buffer[].
			NRF24L01ReadBuffer(RD_RX_PLOAD, SPI_Buffer, rx_pw);

			gIRQ_Source = RX_DR; // Indicates RX data received
		}
		
		break;
	}
}

__enable_irq();

Any help would be greatly appreciated.

Related