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

esb nRF24LU and nRF51822

I am trying to get enhanced shockburst working with the nRF24LU and the nRF5188. I am using the nRF5188 as the transmitter and the nRF24LU as the receiver. I am using the nRF51 sdk version 6. The example that I am using for the nRF51822 is the esb_ptx_ack_payload. Everything in this example has been left in its default state. The nRF24LU is using the enhanced_shockburst_prx_nrf24lu1p example found in the nrfgo_sdk. I read the user guide which said that I have to add the following code to the nRF24LU in order to make it compatible with the nRF51822:

hal_nrf_setup_dynamic_payload(0xFF);
hal_nrf_enable_dynamic_payload(true);
hal_nrf_enable_ack_payload(true);
hal_nrf_set_rf_channel(10);

For some reason its still not working. The odd thing is that when I run the nRF24LU code on one computer and the nRF51822 code on another computer, I can actually send ACKs from the nRF24LU to the nRF5188, but only if I use break points. If I let the code run without breakpoints, no data is transmitted. Also, the data being sent from the nRF51822 never reaches the nRF24LU. Here is the code for the nRF24LU:

#ifdef MCU_NRF24LU1P
#include "nrf24lu1p.h"
#endif

#include <stdint.h>
#include "hal_nrf.h"

// Global variables
uint8_t tx_payload[1];
uint8_t rx_payload[1];

void main()
{
#ifdef MCU_NRF24LE1
	while(hal_clk_get_16m_source() != HAL_CLK_XOSC16M)
	{
		// Wait until 16 MHz crystal oscillator is running
	}
#endif
	
	#ifdef MCU_NRF24LU1P
	// Enable radio SPI
	RFCTL = 0x10;
	#endif

	// Set P0 as output
	P0DIR = 0;

	// Enable the radio clock
	RFCKEN = 1;

	// Enable RF interrupt
	RF = 1;
	// Enable global interrupt
	EA = 1;
	
	hal_nrf_setup_dynamic_payload(0xFF);
	hal_nrf_enable_dynamic_payload(true);
	hal_nrf_enable_ack_payload(true);
	hal_nrf_set_rf_channel(10);
	
	// Configure radio as primary receiver (PTX)
	hal_nrf_set_operation_mode(HAL_NRF_PRX);
	
	// Set payload width to 1 byte
	hal_nrf_set_rx_payload_width((int)HAL_NRF_PIPE0, 1);
	
	// Power up radio
	hal_nrf_set_power_mode(HAL_NRF_PWR_UP);

	// Enable receiver
	CE_HIGH();
}

// Radio interrupt
NRF_ISR()
{
	uint8_t irq_flags;

	// Read and clear IRQ flags from radio
	irq_flags = hal_nrf_get_clear_irq_flags();

	// If data received
	if((irq_flags & (1<<(uint8_t)HAL_NRF_RX_DR)) > 0)
	{
		// Read payload
		while(!hal_nrf_rx_fifo_empty())
		{
			hal_nrf_read_rx_payload(rx_payload);
		}

		// Write received payload[0] to port 0
		P0 = rx_payload[0];
		
		//Write ACK
		tx_payload[0] = 0x88;
		hal_nrf_write_ack_payload(HAL_NRF_PIPE0,tx_payload,1);
	}
}

Any ideas? I think that since I can receive ACKs while debugging, it sounds like a synchronization problem. The only difference between using break points and not using them is that the code is slowed down. So, if I slow the code down I can receive ACKs, but what about the data being sent from the nRF51822? How come I don't receive that?

Parents Reply Children
No Data
Related