|
|||||||||||
| 技術交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術 | 電源技術 | 測控之家 | EMC技術 | ARM技術 | EDA技術 | PCB技術 | 嵌入式系統(tǒng) 驅動編程 | 集成電路 | 器件替換 | 模擬技術 | 新手園地 | 單 片 機 | DSP技術 | MCU技術 | IC 設計 | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe |
〔急急!〕請教周工(在線等待),快被2210的串口給搞瘋了 |
| 作者:eaivip 欄目:ARM技術 |
#include "flash.h" #include "uart.h" #include "addr.h" #include "api.h" #define UART0BAUD 115200 #define LEDNUM 1 /******************************************* ** uart0IRQ() ********************************************/ void __irq uart0IRQ() { uint8 u8data; uint8 r; uint16 i; if((U0IIR & 0x0f)==0x04) { VICIntEnClr=(1<<6); // clear the interrupt r=uartGetByte(&u8data); if(r) uartSendByte(u8data); } VICVectAddr=0; // clear the interrupt VICIntEnable=(1<<6); } /******************************************** ** 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 sending } /******************************************** ** uartGetByte() ********************************************/ uint8 uartGetByte(uint8 * data) { uint8 TEMP; uint16 timeDelay=0; while((U0LSR&0x01)==0) { if(++timeDelay==0) return FALSE; } TEMP=U0RBR; *data=TEMP; return TRUE; } 上面是我的一節(jié)程序,再簡單不過的一個功能 就是要寫一個通信協(xié)議 可是我發(fā)現(xiàn)從串口發(fā)過去的數(shù)據(jù) 和返回的數(shù)據(jù)不一樣 比如發(fā)送0x11 返回的卻是 0xdd 請周工幫我看一下 到底是怎么回事兒 第一次拿ARM做產(chǎn)品 沒想到在這兒被卡住了 從昨天調到今天弄了一整天 現(xiàn)在頭都大了 還是不知道問題出在哪里 請周工幫忙解決一下 在線急切等待回復 * - 本貼最后修改時間:2005-12-28 9:42:46 修改者:eaivip |
| 2樓: | >>參與討論 |
| 作者: dracoduan 于 2005/12/30 10:49:00 發(fā)布:
波特率不匹配? 樓主給的信息不多 另外周立功的easyARM和winXP自帶的超級終端有沖突,會無法接收數(shù)據(jù) |
|
| 3樓: | >>參與討論 |
| 作者: 寒夜 于 2005/12/30 21:50:00 發(fā)布:
檢查中斷中接收到的數(shù)據(jù) 在中斷程序中檢查一下接收到的數(shù)據(jù)是什么? 同時,在用示波器檢測一下RXD引腳上的數(shù)據(jù),判斷問題出現(xiàn)在哪里? |
|
| 4樓: | >>參與討論 |
| 作者: Thristin 于 2005/12/31 9:06:00 發(fā)布:
re 俺不用超級終端,用丁丁串口工具。 |
|
| 5樓: | >>參與討論 |
| 作者: xfarm 于 2005/12/31 9:37:00 發(fā)布:
去掉這句即可: while((U0LSR&0x40)==0); |
|
|
|
| 免費注冊為維庫電子開發(fā)網(wǎng)會員,參與電子工程師社區(qū)討論,點此進入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號 |