公司项目已进入小批量测试阶段了,方案使用的是CH32V307+IP101G,频繁出现接收帧错误,导致设备网络无法正常通讯。当DMA产生中断后,使用的接收处理函数如下:
FrameTypeDef ETH_RxPkt_ChainMode(void) { u32 framelength = 0; FrameTypeDef frame = {0,0}; /* Check if the descriptor is owned by the ETHERNET DMA (when set) or CPU (when reset) */ if((DMARxDescToGet->Status & ETH_DMARxDesc_OWN) != (u32)RESET) { frame.length = ETH_ERROR; if ((ETH->DMASR & ETH_DMASR_RBUS) != (u32)RESET) { /* Clear RBUS ETHERNET DMA flag */ ETH->DMASR = ETH_DMASR_RBUS; /* Resume DMA reception */ ETH->DMARPDR = 0; } DEBUG_PRINTF("Error:ETH_DMARxDesc_OWN.\r\n"); /* Return error: OWN bit set */ return frame; } if( ((DMARxDescToGet->Status & ETH_DMARxDesc_ES) == (u32)RESET) && ((DMARxDescToGet->Status & ETH_DMARxDesc_LS) != (u32)RESET) && ((DMARxDescToGet->Status & ETH_DMARxDesc_FS) != (u32)RESET)) { /* Get the Frame Length of the received packet: substruct 4 bytes of the CRC */ framelength = ((DMARxDescToGet->Status & ETH_DMARxDesc_FL) >> ETH_DMARxDesc_FrameLengthShift) - 4; /* Get the addrees of the actual buffer */ frame.buffer = DMARxDescToGet->Buffer1Addr; } else { /* Return ERROR */ framelength = ETH_ERROR; printf("Error:recv error frame,status:0x%08x.\r\n",DMARxDescToGet->Status); printf("ETH->DMASR:0x%x.\r\n", ETH->DMASR); } DMARxDescToGet->Status|=ETH_DMARxDesc_OWN; frame.length = framelength; frame.descriptor = DMARxDescToGet; /* Update the ETHERNET DMA global Rx descriptor with next Rx decriptor */ /* Chained Mode */ /* Selects the next DMA Rx descriptor list for next buffer to read */ DMARxDescToGet = (ETH_DMADESCTypeDef*) (DMARxDescToGet->Buffer2NextDescAddr); /* Return Frame */ return (frame); }
调试打印信息如下:
I/elog EasyLogger V2.2.99 is initialize success. I/APP.MAIN CPU Freq:144000000 Hz I/APP.MAIN Kernel Version:V10.4.6 I/APP.MAIN HardWare Version: VA3 I/APP.MAIN SoftWare Version: V1.2.7 I/ip101 IP101G初始化成功,ID:2430C54 I/APP.ETH The network cable is not connected! I/ethernet 网络模式切换为:100M全双工 I/APP.ETH The network cable is now connected! I/APP.ETH ip_addr = 192.168.0.193 I/APP.ETH netmask = 255.255.255.0 I/APP.ETH gateway = 192.168.0.1 Error:recv error frame,status:0x004e8b20. ETH->DMASR:0x690414. Error:recv error frame,status:0x00468b20. ETH->DMASR:0x690414.
接收描述符状态值0x004e8b20,说明了ES标志置位了,也就是OE置位了,即溢出错误了。请问下,出现这种问题需要怎么去解决?
热门产品 :
CH634: 4端口USB3.0 HUB控制器芯片