|
本帖最后由 tracy 于 2020-8-15 16:33 编辑
移植坛主基于STM32F401的tuzhuke-twr_location_v1版本程序到stm32f072芯片;现在标签端程序运行时,dw1000的接收发送指示灯都会闪烁;但是基站端只有接收指示灯闪烁;调试基站端程序发现:基站接收程序能够进接收中断回调处理函数,但是一直卡在 if (status_reg & SYS_STATUS_RXFCG)这句,接收失败。因为我的板子没有PA,移植过程中我直接把tuzhuke-twr_location_v1中的PA相关程序注释掉了,不知道有没有影响。我强制进入 if (status_reg & SYS_STATUS_RXFCG)语句,将接收到的数据打印出来,发现接收到的数据和标签发送的数据不一致。现在没有了调试思路,走投无路,来找坛主大神和坛友指导,万分感谢!
- int rx_main(void)
- {
- dwt_setrxaftertxdelay(RESP_TX_TO_FINAL_RX_DLY_UUS);
- //dwt_setrxtimeout(FINAL_RX_TIMEOUT_UUS);
- //dwt_setpreambledetecttimeout(PRE_TIMEOUT);
- dwt_setrxtimeout(0);
- dwt_enableframefilter(DWT_FF_DATA_EN);
- dwt_rxenable(0);
- bphero_setcallbacks(Simple_Rx_Callback);
- //KalMan_Init();
- if(SHORT_ADDR == 0x0001)
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_SET);
- // if(SHORT_ADDR == 0x0002)
- // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_SET);
- // if(SHORT_ADDR == 0x0003)
- // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3, GPIO_PIN_SET);
- while (1)
- {
- }
- }
复制代码- void Simple_Rx_Callback()
- {
- uint32 status_reg = 0,i=0;
- uint32 poll_tx_ts, resp_rx_ts, final_tx_ts;
- uint32 poll_rx_ts_32, resp_tx_ts_32, final_rx_ts_32;
- double Ra, Rb, Da, Db;
- int64 tof_dtu;
- char dist_str[16] = {0};
- for (i = 0 ; i < FRAME_LEN_MAX; i++ )
- {
- rx_buffer[i] = '\0';
- }
- dwt_enableframefilter(DWT_FF_RSVD_EN);//disable recevie
- status_reg = dwt_read32bitreg(SYS_STATUS_ID);
- //printf("RECIEVE POLL MESSAGE00!\r\n");
- <font color="#ff0000"><b> if (status_reg & SYS_STATUS_RXFCG)</b></font>
- {
- /* A frame has been received, copy it to our local buffer. */
- printf("RECIEVE POLL MESSAGE11!\r\n");
- frame_len = dwt_read32bitreg(RX_FINFO_ID) & RX_FINFO_RXFL_MASK_1023;
-
- if (frame_len <= FRAME_LEN_MAX)
- {
- dwt_readrxdata(rx_buffer, frame_len, 0);
- msg_f = (srd_msg_dsss*)rx_buffer;
- msg_f_send.destAddr[0] = msg_f->sourceAddr[0];
- msg_f_send.destAddr[1] = msg_f->sourceAddr[1];
- msg_f_send.seqNum = msg_f->seqNum;
- //printf("RECIEVE DATA type:%c\r\n",msg_f->messageData[0]);
- //printf("0x%04X <--> 0x%02X%02X\r\n",SHORT_ADDR,msg_f->sourceAddr[1],msg_f->sourceAddr[0]);
- switch(msg_f->messageData[0])
- {
- case 'P':
- printf("RECIEVE DATA LEN:%d\r\n",frame_len);
- // printf("RECIEVE DATA LEN:%u\r\n",msg_f->messageData[0]);
- msg_f_send.messageData[0]='A';//Poll ack message
- int temp = (int)(distance[msg_f_send.destAddr[0]]*100);//convert m to cm
- msg_f_send.messageData[1]=temp/100;
- msg_f_send.messageData[2]=temp%100;
- // dwt_writetxdata(ANCH_RESPONSE_MSG_LEN, (uint8 *)&msg_f_send, 0) ; // write the frame data
- // dwt_writetxfctrl(ANCH_RESPONSE_MSG_LEN, 0);
- dwt_writetxdata(14, (uint8 *)&msg_f_send, 0) ; // write the frame data
- dwt_writetxfctrl(14, 0);
- //printf("RECIEVE POLL MESSAGE!\r\n");
- /* Start transmission. */
- dwt_starttx(DWT_START_TX_IMMEDIATE);
- //MUST WAIT!!!!!
- while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS))
- { };
- poll_rx_ts = get_rx_timestamp_u64();
- break;
- case 'F':
- resp_tx_ts = get_tx_timestamp_u64();
- final_rx_ts = get_rx_timestamp_u64();
- final_msg_get_ts(&msg_f->messageData[FINAL_MSG_POLL_TX_TS_IDX], &poll_tx_ts);
- final_msg_get_ts(&msg_f->messageData[FINAL_MSG_RESP_RX_TS_IDX], &resp_rx_ts);
- final_msg_get_ts(&msg_f->messageData[FINAL_MSG_FINAL_TX_TS_IDX], &final_tx_ts);
- poll_rx_ts_32 = (uint32)poll_rx_ts;
- resp_tx_ts_32 = (uint32)resp_tx_ts;
- final_rx_ts_32 = (uint32)final_rx_ts;
- Ra = (double)(resp_rx_ts - poll_tx_ts);
- Rb = (double)(final_rx_ts_32 - resp_tx_ts_32);
- Da = (double)(final_tx_ts - resp_rx_ts);
- Db = (double)(resp_tx_ts_32 - poll_rx_ts_32);
- tof_dtu = (int64)((Ra * Rb - Da * Db) / (Ra + Rb + Da + Db));
- tof = tof_dtu * DWT_TIME_UNITS;
- distance_temp = tof * SPEED_OF_LIGHT;
- distance[msg_f_send.destAddr[0]] = distance_temp - dwt_getrangebias(config.chan,(float)distance_temp, config.prf);//¾ààë¼õ襽ÃÕyÏμêy
- //kalman filter
- //distance[msg_f_send.destAddr[0]] = KalMan(distance[msg_f_send.destAddr[0]]);
- printf("0x%04X <--> 0x%02X%02X :%.02f cm\n",SHORT_ADDR,msg_f_send.destAddr[1],msg_f_send.destAddr[0],distance[msg_f_send.destAddr[0]]);
- // sprintf(dist_str, " Dis: %.02f m", distance[msg_f_send.destAddr[0]]);//m
- // OLED_ShowString(0, 6,dist_str);
- break;
- case 'M':
- USART_puts(&msg_f->messageData[1],16);
- break;
- default:
- break;
- }
- }
- dwt_write32bitreg(SYS_STATUS_ID, (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR));
- dwt_enableframefilter(DWT_FF_DATA_EN);
- // dwt_setrxtimeout(0);
- dwt_rxenable(0);
- }
- else
- {
- dwt_write32bitreg(SYS_STATUS_ID, (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR));
- //enable recive again
- dwt_enableframefilter(DWT_FF_DATA_EN);
- dwt_rxenable(0);
- }
- }
复制代码
|
|