|
|||||||||||
| 技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng) 驅(qū)動(dòng)編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計(jì) | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe |
請問周工關(guān)于串口接收的問題 |
| 作者:eaivip 欄目:ARM技術(shù) |
以下是我的一塊程序: void __irq uart0IRQ() { uint8 u8data,handShake[6]; uint8 cmmd; uint8 shakeFlag,downFlag,r; uint16 i,TEMP; uint32 addr; shakeFlag=TRUE; downFlag=TRUE; if(U0IIR & 0x0f) { VICIntEnClr=0x06; // clear the interrupt //************ handshake ***************** for(i=0;i<4;i++) { r=uartGetByte(&u8data); if(!r) { shakeFlag=FALSE; break; } handShake[i]=u8data; } while(++i==0); for(i=0;i<4;i++) uartSendByte(handShake[i]); //*********** command execution ********** } VICVectAddr=0; // clear the interrupt VICIntEnable=0x06; } /******************************************** ** uartInit() ********************************************/ void uartInit(void) { uint32 TEMP; uint16 Fdiv; TEMP=(PINSEL0&0xfffffff0)|0x05; //SELECT RxD0 & TxD0 PINSEL0=TEMP; U0LCR=0x83; //set the work mode Fdiv=(Fpclk/16)/UART0BAUD; //set the baud rate U0DLM=Fdiv/256; U0DLL=Fdiv%256; U0LCR=0x03; // set the UART0's interrupt U0IER=(U0IER & 0xf8)|0x01; U0IER=0x01; //enable U0 receive interrupt VICVectCntl0=0x20|0x06; // set IRQ slot0 VICVectAddr0=(uint32) uart0IRQ; //set IRQ entry VICIntEnable=1<<6; //enable uart interrupt } /******************************************** ** uartSendByte() ********************************************/ void uartSendByte(uint8 data) { U0THR=data; while((U0LSR&0x40)==0); //wait the end of the data } /******************************************** ** uartGetByte() ********************************************/ uint8 uartGetByte(uint8 *data) { uint32 timeDelay; while(!(U0LCR&0x01)) { if(++timeDelay==0) return FALSE; } *data=U0RBR; return TRUE; } 運(yùn)行過程中 向串口送數(shù)據(jù) 返回值全卻全為0 這是怎么回事兒 |
| 2樓: | >>參與討論 |
| 作者: 寒夜 于 2005/12/27 20:44:00 發(fā)布:
檢查一下中斷 從你這段程序來看,程序中斷處理程序中的 VICIntEnClr=0x06和VICIntEnable=0x06語句好象有點(diǎn)問題. 應(yīng)該是VICIntEnClr=(1<<6)和VICIntEnable=(1<<6)吧! 還有你應(yīng)該確認(rèn)一下,是否真正進(jìn)入了中斷程序. |
|
|
|
| 免費(fèi)注冊為維庫電子開發(fā)網(wǎng)會(huì)員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號(hào) |