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

How to update the RADIO payload in nRF51822?

Hi, All!

I'm using nRF51822 to support custom protocol, and define array "packet[40]" for PACKETPTR. when "packet" is constant value, the radio tx is very stable; but when I update the "packet" with some variable, the radio looks like not very good. Could you help me, please?

This is my code for radio tx:

	uint8_t i, packet[40];
static uint16_t test = 1000;

/* update payload */
test++;
if (test >= 2000) test = 1000;	
for (i = 0; i < 40; i++) {
	if (i % 2 == 0) {
		packet[i] = (uint8_t)(test >> 8);
	} else {
		packet[i] = (uint8_t)(test >> 0);
	}
}

/* DISABLE radio */
NRF_RADIO->SHORTS = 0;
NRF_RADIO->EVENTS_DISABLED = 0;
NRF_RADIO->TASKS_DISABLE = 1;
while (NRF_RADIO->EVENTS_DISABLED == 0);
NRF_RADIO->EVENTS_DISABLED = 0;

/* set packet pointer */
NRF_RADIO->PACKETPTR = (uint32_t)packet;

/* wait for READY event */
NRF_RADIO->EVENTS_READY = 0U;
NRF_RADIO->TASKS_TXEN = 1;
while (NRF_RADIO->EVENTS_READY == 0U);

/* START radio and wait for END event */
NRF_RADIO->TASKS_START = 1U;
NRF_RADIO->EVENTS_END = 0U;
while(NRF_RADIO->EVENTS_END == 0U);

/* disable radio */
NRF_RADIO->EVENTS_DISABLED = 0U;
NRF_RADIO->TASKS_DISABLE = 1U;
while(NRF_RADIO->EVENTS_DISABLED == 0U);

Best Regards!

  • You have not explained exactly what the symptoms are. Your code does not check for CRC errors, but CRC errors are common in real world RF environments. It might help if you posted all your code instead of just a fragment.

  • Hi, butch, thank you very much for your reply, I will attach the code later(I'm not in my office now).And, could you tell me how to check the CRC error in TX mode please? I think the CRC status only checked in RX mode.

  • Thank you again! The problem had been sovled, the reason is in the recevier side, because of irregular cycle.("if...else..." caused different process in the receiver, and consumpt different time)