“I am working with the DW3xxx UWB module and using the interrupt-driven callback mechanism for receiving data. I have set up the dwt_setcallbacks()
function to register my callback handlers. However, my RX callback (rx_listener_cb()
) does not always trigger when a packet is received.”
here how i am trying
dwt_setcallbacks(NULL, rx_listener_cb, listener_error_cb, NULL, NULL);
void rx_listener_cb(const dwt_cb_data_t *rxd)
{
char str[MAX_STR_SIZE];
// Read the status register to check the interrupt source
uint32_t status = dwt_readsysstatus();
sprintf(str, "[DEBUG] ISR triggered. SYS_STATUS: 0x%08X\r\n", status);
reporter_instance.print(str, strlen(str));
// Check if a frame has been successfully received
if (status & DWT_INT_RXFCG_BIT_MASK) {
sprintf(str, "[SUCCESS] RX Frame received!\r\n");
reporter_instance.print(str, strlen(str));
// Read received frame data
blink_msg_t rx_blink;
dwt_readrxdata((uint8_t*)&rx_blink, sizeof(blink_msg_t), 0);
sprintf(str, "[SUCCESS] Blink received! SeqNum: %d\r\n", rx_blink.seqNum);
reporter_instance.print(str, strlen(str));
// Clear RX event flag
dwt_writesysstatus(DWT_INT_RXFCG_BIT_MASK);
}
// Enable receiver for next frame
dwt_rxenable(DWT_START_RX_IMMEDIATE);
}
Interrupt Configuration and Reception:
void f_listen()
{
char str[200];
// Soft Reset before Initialization
CMD_ENTER_CRITICAL();
restore_bssConfig();
CMD_EXIT_CRITICAL();
// Initialize DW3xxx
if (dwt_initialise(DWT_DW_INIT) != DWT_SUCCESS) {
sprintf(str, "[ERROR] dwt_initialise() failed!\r\n");
reporter_instance.print(str, strlen(str));
return;
}
// Register Callbacks
dwt_setcallbacks(NULL, rx_listener_cb, listener_error_cb, NULL, NULL);
sprintf(str, "[DEBUG] Callbacks registered successfully!\r\n");
reporter_instance.print(str, strlen(str));
// Enable Interrupts for RX
dwt_setinterrupt(DWT_INT_RXFCG_BIT_MASK, 1);
// Start Listening Mode
dwt_rxenable(DWT_START_RX_IMMEDIATE);
sprintf(str, "[DEBUG] RX Mode Enabled\r\n");
reporter_instance.print(str, strlen(str));
}
now the problem is * The rx_listener_cb()
callback does not always trigger when a packet is received.
- I confirmed that frames are being transmitted, but sometimes the RX interrupt (
DWT_INT_RXFCG_BIT_MASK
) does not fire. - In some cases, the callback triggers but the
dwt_readrxdata()
function returns incorrect or empty data.
Is my callback function rx_listener_cb()
correctly implemented?
Do I need to manually clear the interrupt flag using dwt_writesysstatus()
?
What could cause the callback to not trigger every time a frame is received?
Are there additional interrupt flags I should enable in dwt_setinterrupt()
?
Should I re-enable RX (dwt_rxenable()
) inside the callback or outside?