公司項(xiàng)目已進(jìn)入小批量測試階段了,方案使用的是CH32V307+IP101G,頻繁出現(xiàn)接收幀錯(cuò)誤,導(dǎo)致設(shè)備網(wǎng)絡(luò)無法正常通訊。當(dāng)DMA產(chǎn)生中斷后,使用的接收處理函數(shù)如下:
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); }
調(diào)試打印信息如下:
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?????????網(wǎng)絡(luò)模式切換為: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.
接收描述符狀態(tài)值0x004e8b20,說明了ES標(biāo)志置位了,也就是OE置位了,即溢出錯(cuò)誤了。請問下,出現(xiàn)這種問題需要怎么去解決?
熱門產(chǎn)品 :
CH394: 以太網(wǎng)協(xié)議棧芯片