Hello all,
i am working with the nRF52832 DK and SDK11. Actually the Enhanced Shock Burst Communication is working. I can send and receive messages. From this point on I implemented a Time synchronization with the idea you gave in one blog entry ("Wireless timer synchronization among nRF5 devices"). Really good blog entry by the way.
I needed to implement a timer which helps my by invoking tasks in defined time intervalls like this:
NRF_RADIO->TXADDRESS = mp_current_payload->pipe;
NRF_RADIO->RXADDRESSES = 1 << mp_current_payload->pipe;
NRF_RADIO->FREQUENCY = m_esb_addr.rf_channel;
NRF_RADIO->PACKETPTR = (uint32_t)m_tx_payload_buffer;
NVIC_ClearPendingIRQ(RADIO_IRQn);
NVIC_EnableIRQ(RADIO_IRQn);
NRF_RADIO->EVENTS_ADDRESS = 0;
NRF_RADIO->EVENTS_PAYLOAD = 0;
NRF_RADIO->EVENTS_DISABLED = 0;
NRF_TIMER3->SHORTS = TIMER_SHORTS_COMPARE1_STOP_Msk | TIMER_SHORTS_COMPARE1_CLEAR_Msk;
NRF_TIMER3->TASKS_STOP = 1;
NRF_TIMER3->TASKS_CLEAR = 1;
NRF_TIMER3->CC[0] = 45; // Matches 40 us radio ramp up time
NRF_TIMER3->CC[1] = 60; // Margin for timer readout
NRF_TIMER3->EVENTS_COMPARE[0] = 0;
NRF_TIMER3->EVENTS_COMPARE[1] = 0;
DEBUG_PIN_SET(DEBUGPIN4);
NRF_RADIO->TASKS_TXEN = 1;
NRF_TIMER3->TASKS_START = 1;
while (NRF_TIMER3->EVENTS_COMPARE[0] == 0);
NRF_TIMER0->TASKS_CAPTURE[2] = 1;
m_tx_payload_buffer[2] = (NRF_TIMER0->CC[2] & 0xFF00) >> 8;
m_tx_payload_buffer[3] = (NRF_TIMER0->CC[2] & 0x00FF);
Actually the ESB protocol has some shorts prefedined:
#define RADIO_SHORTS_COMMON ( RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_END_DISABLE_Msk | \
RADIO_SHORTS_ADDRESS_RSSISTART_Msk | RADIO_SHORTS_DISABLED_RSSISTOP_Msk )
For my case I dont need the RADIO_SHORTS_READY_START_Msk Short because I has to start the transmission by my NRF_TIMER3 if the COMPARE[1] is expired. So I deleted this short and additionally I initialized a ppi to start the transmission:
err_code = nrf_drv_ppi_init();
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_ppi_channel_alloc(&sync.ppi_channel3);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_ppi_channel_assign(sync.ppi_channel3,
nrf_drv_timer_event_address_get(&TIMER_CAPTURE, NRF_TIMER_EVENT_COMPARE1),
(uint32_t)&NRF_RADIO->TASKS_START);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_ppi_channel_enable(sync.ppi_channel3);
Before I get rid of the Short and initializing the ppi I can receive messages on the PRX side. Afterwords I can't even though the EVENT_END event is occuring. That means the message is transmitted. What did I wrong. I have no further idea.
Thanks for help,
Florian