I have the following set up:
1) an NRF timer which triggers the timer-handler
2) an NRF radio peripheral which is triggered by the timer-handler
3) an NRF radio transmission which is fired in radio-handler
Timer-handler (interrupt routine):
void timer1_interrupt_handler(nrfx_timer_event_handler_t evt, void * p_context) { LOG_INF("========= Timer1 HANDLER ========="); radio_interup_counter = 0; NRF_TIMER1 -> EVENTS_COMPARE[0] = 0; // Loging radio state before its activation state0 = nrf_radio_state_get(NRF_RADIO); // Reseting interupt setting and configuration nrf_radio_int_disable(NRF_RADIO, 0xFFFFFFFF); nrf_radio_int_enable(NRF_RADIO, NRF_RADIO_INT_END_MASK | NRF_RADIO_INT_READY_MASK); // Dummy packets to be sent by the radio interupt to follow // (Packets are already declared globally) packet.x = 23; packet.z = 67; packet.z = 15; // Packet pointer assignment NRF_RADIO->PACKETPTR = (uint32_t) &packet; // Firing the radio! NRF_RADIO->TASKS_TXEN = 1; }
Radio handler (interrupt routine):
ISR_DIRECT_DECLARE(RADIO_ISR) { radio_interup_counter ++; if (radio_interup_counter == 1){ LOG_INF("======= First RADIO HANDLER ======="); } // TASK-Start when READY is received if (NRF_RADIO->EVENTS_READY == 1) { NRF_RADIO->EVENTS_READY = 0; NRF_RADIO->TASKS_START = 1U; // Loging NRF_RADIO State state1 = nrf_radio_state_get(NRF_RADIO); } // Disabling Radio when END is received if (NRF_RADIO->EVENTS_END == 1) { NRF_RADIO->EVENTS_END = 0; NRF_RADIO->TASKS_DISABLE = 1U; // Loging NRF_RADIO State state2 = nrf_radio_state_get(NRF_RADIO); } // Creating some extra logging information (ADDRESS and Payload signals) if (NRF_RADIO->EVENTS_ADDRESS == 1U){ state3 = 20; } else {state3 = 0;} state4 = 0; if (NRF_RADIO->EVENTS_PAYLOAD == 1U){ state4 = 30; } if (radio_interup_counter == 2){ //======================================================= // Loging Radio State Transitions LOG_INF(" Step_a: %d, Step_b: %d, Step_c: %d, Address: %d, Payload: %d", state0, state1, state2, state3, state4); LOG_INF("======= Last RADIO HANDLER ======="); } ISR_DIRECT_PM(); return 1; }
This is the Log information
[00:08:01.192,962] <inf> Logging_Name:========= Timer1 HANDLER ========= [00:08:01.215,393] <inf> Logging_Name:======= First RADIO HANDLER ======= [00:08:01.237,915] <inf> Logging_Name: Step_a: 0, Step_b: 11, Step_c: 12, Address: 20, Payload: 30 [00:08:01.262,817] <inf> Logging_Name:======= Last RADIO HANDLER =======
which means:
We do a full cycle of "Radio off (0)", "Transmission (11)", and "disabling (12)" where we received "Address" and "Payload" transmission signals.
Although this log shows that the radio is sending something, I do not get any message on my wireshark which is hooked up to the NRF_SINFFER.
MOREOVER: I tried to verify transmission by checking the power consumption of the DK.
This is the power-profile of this process that I get using NRF PPK2:
which clearly shows that NRF_RADIO is triggered every 2 seconds which is the timer timeout that I set;
if we look deeper:
Comparing to the NRF power online profiler for nrf52840, this does not show that the radio is actually sending anything.
For the radio configuration, I do the following:
static void radio_configure(void) { const nrf_radio_packet_conf_t pkt_conf = { .lflen = 0, .s0len = 0, .s1len = 0, .maxlen = sizeof(struct packet_structure), .statlen = 0, .balen = 4, .big_endian = true, .whiteen = true, }; nrf_radio_power_set(NRF_RADIO, true); nrf_radio_txpower_set(NRF_RADIO, NRF_RADIO_TXPOWER_0DBM); nrf_radio_mode_set(NRF_RADIO, RADIO_MODE_MODE_Ble_1Mbit); nrf_radio_modecnf0_set(NRF_RADIO, true, RADIO_MODECNF0_DTX_Center); nrf_radio_crc_configure(NRF_RADIO, 3, NRF_RADIO_CRC_ADDR_INCLUDE, 0x11021UL); nrf_radio_crcinit_set(NRF_RADIO, 0xFFFFFFUL); nrf_radio_packet_configure(NRF_RADIO, &pkt_conf); // Creating the access address uint32_t ACCESS_ADDRESS[5] = {0x8E, 0x89, 0xBE, 0xD6}; nrf_radio_base0_set(NRF_RADIO, ACCESS_ADDRESS[2] << 24 | ACCESS_ADDRESS[1] << 16 | ACCESS_ADDRESS[0] << 8); nrf_radio_prefix0_set(NRF_RADIO, ACCESS_ADDRESS[0]); nrf_radio_txaddress_set(NRF_RADIO, 0); nrf_radio_rxaddresses_set(NRF_RADIO, BIT(0)); uint32_t Channel_Frequency = 80; NRF_RADIO->FREQUENCY = Channel_Frequency; nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_END); }
I will be really thankful if you could help me understand why this code does not work.
I have checked almost everything, but still I am not able to figure out why this code does not work (does not send packets).
Any help or suggestion is very much appreciated.