Hi all,
I am working on a project with 2 kind of messages:
- message A needs a delayed response (to compute distances between antennas)
- message B has no response at all
The system works fine for both messages when using single buffer mode.
So I tried to support double buffer mode using the following pattern:
SETUP:
…
dwt_setdblrxbuffmode(1);
dwt_setcallbacks(&tx_conf_cb, &rx_ok_cb, &rx_to_cb, &rx_err_cb);
dwt_setinterrupt(DWT_INT_TFRS | DWT_INT_RFCG | DWT_INT_RFTO | DWT_INT_RXPTO |
DWT_INT_RPHE | DWT_INT_RFCE | DWT_INT_RFSL | DWT_INT_SFDT, 1);
dwt_setrxtimeout(0);
dwt_setrxaftertxdelay(0);
dwt_rxenable(DWT_START_RX_IMMEDIATE);
RECEIVE CALLBACK:
dwt_rxenable(DWT_START_RX_IMMEDIATE | DWT_NO_SYNC_PTRS);
length = MIN(cb_data->datalength,RX_BUF_LEN);
dwt_readrxdata(buffer, length, 0);
switch (message ID)
case MESSAGE A (with delayed response):
dwt_forcetrxoff();
dwt_readrxtimestamp(ts_tab);
dwt_setdelayedtrxtime(ts_tab + DELAY);
dwt_writetxdata(sizeof(resp_msg), (uint8*)&resp_msg, 0);
dwt_writetxfctrl(sizeof(resp_msg), 0, 1);
dwt_starttx(DWT_START_TX_DELAYED);
break;
case MESSAGE B (no response required):
just process incoming message data
break;
Message type B still works in double buffer mode.
But when I receive the first instance of message A the receive callback
function is continuously invoked by dwt_isr always with the same message.
Interrupt pin is never reset causing dwt_isr being reentered and system hangs
Any suggestion and/or code sample to support double buffer with delayed
transmission will be highly appreciated !
Best regards,
PaoloC