Hi, I am interfacing a TI TM4C123 microcontroller to the AddiCore nRF24L01+ Transceiver Module. I can consistently transmit and receive data with the microcontroller/nRF24L01+ modules, however the PTX does not receive the ACK from PRX. Using UARTs connected to each of the PTX and PRX, I can see the PRX receives the packet correctly but I don't get the ACK at the PTX. I have included the code to set-up the nRF24L01+ in PTX or RTX modes. Any help would be appreciated.
// Switch has been pressed.
// Initialize Wireless Interface (nRF24L01+)
// ************************************************************
// Transmitter
// ************************************************************
if (PF_In & 0x10) {
// Switch 2 has been pressed to configure as transmitter.
// Set up Nordic nRF24L01+ in transmit mode
// Initialize the 24L01+ to the debug configuration as TX, x data byte, and auto-ack enabled
nrf24l01_initialize_debug(false, NUMBYTES_PERPACKET, true);
GPIO_PORTF_DATA_R |= 0x04; // turn on blue LED
// Display message by sending to UART
UART_OutString((unsigned char*)"Transmit Mode Selected *");
UART_sendCRLF( );
// ***********************************************************************
// ***********************************************************************
// Transmitter Loop
while(1) {
UART_sendCRLF( );
UART_sendCRLF( );
UART_OutString((unsigned char*)"---------------------------- *");
UART_sendCRLF( );
UART_OutString((unsigned char*)"Transmission Cycle = *"); // tx_cycle
UART_OutChar(tx_cycle);
UART_sendCRLF( );
tx_cycle++;
// Wait until either switch is pressed
PF_In = GPIO_PORTF_DATA_R&0x11; // read Sw1 & SW2
while (PF_In == 0x11) {
PF_In = GPIO_PORTF_DATA_R&0x11; // Check SW1 and SW2
};
// Load data array
for (indx=0; indx<NUMBYTES_PERPACKET; indx++) {
operator_input[indx] = tx_cycle + indx;
}
UART_OutString((unsigned char*)"Assigned input: *");
UART_OutChar(operator_input[0]);
UART_sendCRLF( );
nrf24l01_write_tx_payload(operator_input, pack_length, true); // write data to TX Fifo
// wait until the nRF24L01+ IRQ pin is active (either RX_DR or MAX_RT flags active)
while(!nrf24l01_irq_pin_active()) {};
// Read status register
nrf24l01_read_register(nrf24l01_STATUS, &status_reg, 1);
status_reg &= nrf24l01_CONFIG_MASK_RX_DR; // mask all bits but RX_DR
if(status_reg == nrf24l01_CONFIG_MASK_RX_DR) {
nrf24l01_irq_clear_all(); //clear all interrupts in the 24L01
nrf24l01_read_rx_payload(&data_transmit, pack_length); //get the payload into data
nrf24l01_irq_clear_all(); //clear interrupts again
UART_sendCRLF( );
UART_OutString((unsigned char*)"Transmit Done. *");
UART_sendCRLF( );
UART_OutString((unsigned char*)"Ack Data Received: *");
UART_OutChar(data_transmit);
UART_sendCRLF( );
delay_us(130); //wait for receiver to come from standby to RX
delay_us(200000); // debounce switches
GPIO_PORTF_DATA_R ^= 0x04; // toggle blue LED
}
// Maximum number of retries has been reached.
else {
nrf24l01_flush_tx(); //get the unsent character out of the TX FIFO
nrf24l01_irq_clear_all(); //clear all interrupts
UART_OutString((unsigned char*)"Max num of retries reached. Ack was not received. *");
UART_sendCRLF( );
delay_us(200000); // debounce switches
GPIO_PORTF_DATA_R ^= 0x04; // toggle blue LED
}
}
}
// ***********************************************************************
// ***********************************************************************
// Receiver
else {
// Switch 1 has been pressed to configure as receiver.
// Set up Nordic nRF24L01+ in receive mode
// Initialize the 24L01+ to the debug configuration as RX, 1 data byte, and auto-ack enabled
nrf24l01_initialize_debug(true, NUMBYTES_PERPACKET, true);
GPIO_PORTF_DATA_R |= 0x08; // turn on green LED
UART_OutString((unsigned char*)"Receive Mode Selected *");
UART_sendCRLF( );
//main RX program loop
while(1) {
UART_OutString((unsigned char*)"Waiting for Receiver command. *");
UART_sendCRLF( );
recd_cmd = 0x00; // clear received command
// clear all interrupts and flush both TX and RX Fifos
nrf24l01_clear_flush(); // ab July 28, 2014
//wait until a packet has been received; IRQ pin will go low
while(!nrf24l01_irq_pin_active()) {};
delay_us(230); //wait for the other 24L01 to come from standby to RX
// Read one extra byte from the RX Fifo. The first is the Status Register,
// the rest of the bytes are the received data.
nrf24l01_read_rx_payload(buf_array, NUMBYTES_PERPACKET+1); //read the packet into data
UART_OutString((unsigned char*)"Status Register value: *");
UART_OutChar(buf_array[0]); // send received data to UART
UART_sendCRLF( );
// Now send data received to display
for (indx=0; indx < NUMBYTES_PERPACKET; indx++) {
UART_OutString((unsigned char*)"Received Data: *");
UART_OutChar(buf_array[indx+1]); // send received data to UART
UART_sendCRLF( );
}
nrf24l01_irq_clear_all(); //clear interrupts again
GPIO_PORTF_DATA_R ^= 0x08; // toggle green LED
}
}
}