最近要用ch395做服務(wù)器,使用stm32F1的串口(115200)與ch395通信,stm32F1的中斷只有邊沿觸發(fā),我用的下降沿觸發(fā),應(yīng)為用了ucosii,每次來中斷,就給ch395線程發(fā)信號,中斷的處理在線程中,目前通信正常,但是每發(fā)一次數(shù)據(jù),總感覺有無用的中斷,比如發(fā)一次數(shù)據(jù):
(interrpute code:。。。是我在全局中斷中的printf,每進一次全局中斷,查詢中斷代碼,就打印一次)
void?Ch395_task(void?*pdata) { u8?res?=?0,i?=?0,cnt?=?0; INT8U?Err; pdata=pdata; OSTimeDly(100); CH395CMDReset(); OSTimeDly(100); i?=?CH395CMDGetVer(); CH395SetTCPMss(TcpMss);??????????????????????????????????????????/*?定義TCPMSS*/ InitCH395InfParam();?????????????????????????????????????????????/*?初始化CH395相關(guān)變量?*/ i?=?CH395Init();?????????????????????????????????????????????????/*?初始化CH395芯片?*/ mStopIfError(i); printf("ch395?init?succeed!\n"); while((res<=1)&&(cnt<30)) { res?=?CH395CMDGetPHYStatus(); OSTimeDly(1000); cnt++; if((res?!=?PHY_DISCONN)&&(res!=0))?????????????????????/*?查詢CH395是否連接?*/ { CH395Inf.isConnect?=?1; printf("CH395?Connect?Ethernet,spend?%dS\n",cnt);???????????????????????/*?CH395芯片連接到以太網(wǎng),此時會產(chǎn)生中斷?*/ InitSocketParam();????????????????????????????????????????/*?初始化socket相關(guān)變量?*/ CH395SocketInitOpen(); break; } } while(1) {??? OSSemPend(Ch395_interrupt,200,&Err);? if(Err?==?OS_ERR_NONE) { ??CH395GlobalInterrupt(); } else?if(Err?==?OS_ERR_TIMEOUT) { } } }
void?CH395GlobalInterrupt(void) { ????UINT16??init_status; ????UINT8??buf[10];? ? ????init_status?=?CH395CMDGetGlobIntStatus_ALL(); ?? ????printf("interrpute?code?:0x%04x\n",init_status); ????if(init_status?&?GINT_STAT_UNREACH)??????????????????????????????/*?不可達中斷,讀取不可達信息?*/ ????{ ????????CH395CMDGetUnreachIPPT(buf);???????????????????????????????? ????} ????if(init_status?&?GINT_STAT_IP_CONFLI)????????????????????????????/*?產(chǎn)生IP沖突中斷,建議重新修改CH395的?IP,并初始化CH395*/ ????{ ????} ????if(init_status?&?GINT_STAT_PHY_CHANGE)???????????????????????????/*?產(chǎn)生PHY改變中斷*/ ????{ ??????printf("Init?status?:?GINT_STAT_PHY_CHANGE\n"); } ????if(init_status?&?GINT_STAT_SOCK0) ????{ ????????CH395SocketInterrupt(0);?????????????????????????????????????/*?處理socket?0中斷*/ ????} }
[19:19:09.441]收←◆interrpute?code?:0x0010 receive?len?=?13 Tcp?RecvData:1fdgvdfgsdfgv interrpute?code?:0x0010 interrpute?code?:0x0000
看示波器抓的int腳的信號。有的時候,在比較長的低電平那段,還回有一個短時間的上升下降。
一下是收發(fā)一次的。
[18:59:38.719]收←◆interrpute?code?:0x0010 receive?len?=?13 Tcp?RecvData:1fdgvdfgsdfgv interrpute?code?:0x0010 SINT_STAT_SENBUF_FREE interrpute?code?:0x0000 interrpute?code?:0x0000 [18:59:38.841]收←◆interrpute?code?:0x0010
interrpute?code?:0x0000這是怎么回事,另外
[18:59:38.841]收←◆interrpute?code?:0x0010
進入socket中斷后,查詢socket中斷狀態(tài)也是零。這怎么回事啊???
stm32F103沒有低電平中斷。