CH32V307使用ETH DMA,發(fā)現(xiàn)會頻繁進中斷

CH32V307使用ETH DMA + 外置100phy,會頻繁進DMA中斷,發(fā)現(xiàn)在phy link完成之前就會進DMA的TBU中斷,而且這個中斷時持續(xù)的在進。除此之外還會進一個異常中斷,AIS的ET中斷,這兩個中斷進入后僅做了清標(biāo)志位的操作,清空中斷標(biāo)志后,還會頻繁的進,發(fā)生TBU或ET中斷后,需要進行其他操作嗎?

出現(xiàn)TBU和ET中斷,還可以正常通信,當(dāng)出現(xiàn)RBU中斷后,就無法正常通信,進RBU中斷后需要什么操作來恢復(fù)接收呢?

您好

(1)RBU中斷后導(dǎo)致無法正常通信,可在RBU中斷下清除DMA描述符指針的緩沖或者復(fù)位MAC進行復(fù)位操作。

(2)您講述的這些異常中斷的產(chǎn)生可能是時鐘配置誤差造成的,可參考鏈接中的程序(官網(wǎng)的新的NET庫:http://www.findthetime.net/downloads/CH32V307EVT_ZIP.html )的時鐘配置進行更改。


您好

????目前使用外置100M PHY的方案,應(yīng)該不會是時鐘配置的問題


????ETH DMA使用Rx Chain的數(shù)量是4個,當(dāng)前找到一個規(guī)避方法,當(dāng)出現(xiàn)RBU中斷之后在中斷里面

????1、先執(zhí)行ETH->DMASR =?ETH_DMASR_RBUS清空中斷標(biāo)志

????2、然后執(zhí)行ETH->DMARPDR = 0重新啟動DMA的接收流程

????3、最后執(zhí)行DMARxDescToGet = (ETH_DMADESCTypeDef *)(DMARxDescToGet->Buffer2NextDescAddr)切換DMA描述符,經(jīng)過這樣的操作流程后,可以使通信恢復(fù)正常。

? ? ? ? ? ? ETH->DMASR = ETH_DMASR_RBUS;

? ? ? ? ? ? ETH->DMARPDR = 0;

? ? ? ? ? ? DMARxDescToGet = (ETH_DMADESCTypeDef *)(DMARxDescToGet->Buffer2NextDescAddr);


????當(dāng)發(fā)生RBU中斷后,立即查看DMARxDescToGet->Status & ETH_DMARxDesc_OWN的值,發(fā)現(xiàn)他的值為0x8000 0000,切換DMA描述符后(執(zhí)行DMARxDescToGet = (ETH_DMADESCTypeDef *)(DMARxDescToGet->Buffer2NextDescAddr))再次查看DMARxDescToGet->Status & ETH_DMARxDesc_OWN的值為0x0000 0000。是否需要再將切換后的DMA描述符的所屬權(quán)交給DMA控制器(DMARxDescToGet |= ETH_DMARxDesc_OWN)?。出現(xiàn)這樣的情況,通過此種方法解決是否合理?正常的處理流程應(yīng)該是什么樣的呢?


????您回復(fù)說RBU中斷下清除DMA描述符指針的緩沖,DMA描述符指針的緩沖指的是“數(shù)據(jù)緩沖區(qū)”還是“DMA描述符數(shù)組”?


這里是中斷使能配置

ETH_DMAITConfig(ETH_DMA_IT_NIS?|?ETH_DMA_IT_AIS?|?ETH_DMA_IT_R?|?ETH_DMA_IT_RBU,?ENABLE);


以下是ETH中斷服務(wù)

void?ETH_IRQHandler(void)?__attribute__((interrupt("WCH-Interrupt-fast")));
void?ETH_IRQHandler(void)
{
????GET_INT_SP();
????rt_interrupt_enter();

????struct?pbuf?*frame_in_mail?=?NULL;
????struct?pbuf?*frame_in_temp?=?NULL;
????uint8_t?*frame_data_p?=?NULL;

????uint32_t?int_sta?=?ETH->DMASR;

????if?((int_sta?&?ETH_DMA_IT_AIS)?!=?RESET)
????{
????????//?rt_kprintf("AIS?<0x%x>?<0x%x>\n\n",?int_sta,?DMARxDescToGet->Status?&?ETH_DMARxDesc_OWN);
????????if?((int_sta?&?ETH_DMA_IT_RBU)?!=?RESET)
????????{
????????????//?接收緩沖區(qū)不可用
????????????//?rt_kprintf("RBU?<0x%x>\n",?(int_sta?&?ETH_DMA_IT_RBU));
????????????ETH->DMASR?=?ETH_DMASR_RBUS;
????????????ETH->DMARPDR?=?0;
????????????DMARxDescToGet?=?(ETH_DMADESCTypeDef?*)(DMARxDescToGet->Buffer2NextDescAddr);
????????}

????????ETH_DMAClearITPendingBit(ETH_DMA_IT_AIS);
????}

????if?((int_sta?&?ETH_DMA_IT_NIS)?!=?RESET)
????{
????????//?rt_kprintf("NIS?<0x%x>\n",?int_sta);

????????if?((int_sta?&?ETH_DMA_IT_R)?!=?RESET)
????????{
????????????while?((rx_eth_len?=?ETH_HandleRxPkt(rx_eth_buf))?>?16)
????????????{
????????????????if?(eth0_dev.link_status?==?TRUE)
????????????????{
????????????????????frame_data_p?=?rx_eth_buf;
????????????????????frame_in_mail?=?pbuf_alloc(PBUF_RAW,?rx_eth_len,?PBUF_POOL);?//申請存儲空間(這里沒用PBUF_RAM)
????????????????????if?(frame_in_mail?!=?NULL)
????????????????????{
????????????????????????//?拷貝數(shù)據(jù)到PBUF
????????????????????????frame_in_temp?=?frame_in_mail;
????????????????????????while?(frame_in_temp?!=?NULL)
????????????????????????{
????????????????????????????rt_memcpy(frame_in_temp->payload,?frame_data_p,?frame_in_temp->len);
????????????????????????????frame_data_p?+=?frame_in_temp->len;
????????????????????????????frame_in_temp?=?frame_in_temp->next;
????????????????????????}

????????????????????????if?(rt_mb_send_wait(frame_in_mb,?(rt_ubase_t)frame_in_mail,?0)?!=?RT_EOK)
????????????????????????{
????????????????????????????pbuf_free(frame_in_mail);
????????????????????????}
????????????????????}
????????????????????else
????????????????????{
????????????????????????ETH_LOGE(MODULE,?"pbuf=NULL");
????????????????????}
????????????????}
????????????}
????????????ETH_DMAClearITPendingBit(ETH_DMA_IT_R);
????????}

????????if?((int_sta?&?ETH_DMA_IT_TBU)?!=?RESET)
????????{
????????????//?rt_kprintf("TBU?<0x%x>\n",?(int_sta?&?ETH_DMA_IT_TBU));
????????????ETH->DMASR?=?ETH_DMASR_TBUS;
????????????ETH->DMATPDR?=?0;
????????}

????????ETH_DMAClearITPendingBit(ETH_DMA_IT_NIS);
????}

????rt_interrupt_leave();
????FREE_INT_SP();
}



只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频