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

Troubles with reading NRF_RADIO->STATE

Hi,

I use the nRF51822 on the PCA10001 and nRF6310/PCA10005 boards. I modified the radio_tx_example and wanted to read the actual state of the radio. Therefore I used a volatile variable array (volatile uint32_t dummy[10]) to copy the NRF_RADIO->STATE and read them in the debugger mode. The modified main is attached.

int main(void) { volatile uint8_t cnt = 0; volatile uint32_t dummy[10]; /* Start 16 MHz crystal oscillator */ NRF_CLOCK->EVENTS_HFCLKSTARTED = 0; NRF_CLOCK->TASKS_HFCLKSTART = 1;

/* Wait for the external oscillator to start up */ while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) { }

// Set Port 0 as input nrf_gpio_range_cfg_input(0, 7, NRF_GPIO_PIN_PULLUP);

// Set Port 1 as output nrf_gpio_range_cfg_output(8, 15);

// Set radio configuration parameters radio_configure();

// Set payload pointer NRF_RADIO->PACKETPTR = (uint32_t)packet; dummy[0] = NRF_RADIO->STATE; while(true) { // Read Data to send, button signals are default high, low on pressing // packet[0] = ~((uint8_t) (NRF_GPIO->IN)); // Write GPIO to payload byte 0 packet[0] = cnt++;

NRF_RADIO->EVENTS_READY = 0U;

// Enable radio and wait for ready
NRF_RADIO->TASKS_TXEN = 1;

dummy[1] = NRF_RADIO->STATE; while (NRF_RADIO->EVENTS_READY == 0U) { } dummy[2] = NRF_RADIO->STATE; // Start transmission and wait for end of packet. NRF_RADIO->TASKS_START = 1U; dummy[3] = NRF_RADIO->STATE;

NRF_RADIO->EVENTS_END = 0U;

while(NRF_RADIO->EVENTS_END == 0U) // Wait for end
{
}

dummy[4] = NRF_RADIO->STATE;

// Write sent data to port 1
nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, packet[0]);

NRF_RADIO->EVENTS_DISABLED = 0U;

// Disable radio
NRF_RADIO->TASKS_DISABLE = 1U;

while(NRF_RADIO->EVENTS_DISABLED == 0U)
{
}

dummy[5] = NRF_RADIO->STATE;

} }

I set the breakpoint at the end of the while(true) part (@"dummy[5] = NRF_RADIO->STATE") and expected the values from 16.2.22 STATE of the "nRF51_Reference_manual v1.1", but I only read zeros in the dummy array!

Please, could anyone explain me, what I'm doing wrong? Thanks for you help!!

achim

Related