版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上實 驗 報 告課程名稱 嵌入式系統(tǒng)設計 實驗儀器 清華同方辰源嵌入式系統(tǒng)實驗箱 實驗名稱 實驗四:串口傳輸實驗 系 別 計算機學院 專 業(yè) 計算機科學與技術 班級/學號 學生姓名 實驗日期 成 績 指導教師 實驗四:串口傳輸實驗1、 實驗問題回答(1) 本實驗引入了Send和Receive兩個變量表示上傳或下傳數(shù)據(jù),用狀態(tài)機怎么實現(xiàn)?答:switch(oledkey0)case 'F': state=1;/Receive = 1;/Send = 0;break;case 'E': state=2;/Send = 1;/Receive =
2、 0;break;switch(state)case 0:break;case 1: recive();break;case 2:send();break;(2) 了解串口通訊原理。答:串口按位(bit)發(fā)送和接收字節(jié),串口通信最重要的參數(shù)是波特率、數(shù)據(jù)位、停止位和奇偶校驗。對于兩個進行通信的端口,這些參數(shù)必須匹配。1、51系列單片機的串口有4個模式,可分別用作串并轉(zhuǎn)換、并串轉(zhuǎn)換、異步串行通信(2種模式)。異步串行通信中,有1+8+1和1+8+1+1兩種幀格式,多機通信是特殊的通信方式。2、基本原理是兩組移位寄存器。將并行通信轉(zhuǎn)換成串行通信模式(發(fā)送部分),或反之(接收部分)??扇p工運行。3
3、、速度通過移位脈沖決定。具體一般通過定時器1的自動裝載模式產(chǎn)生的溢出脈沖給出。4、電平上采用的是CMOS邏輯。5、以上是物理層和數(shù)據(jù)鏈路層的單片機串口模塊的約定,其他層需要軟件人員根據(jù)需要自行把握。另外,電平需要根據(jù)實際通信環(huán)境做變換,如232、485或紅外等。(3)了解在上位機(PC端)端,C程序中如何調(diào)用串口? 答:#include <Windows.h>#include <stdio.h>HANDLE hCom;int main(void)hCom=CreateFile(TEXT("COM3"),/COM
4、1口GENERIC_READ|GENERIC_WRITE, /允許讀和寫0, /獨占方式NULL,OPEN_EXISTING, /打開而不是創(chuàng)建0, /同步方式NULL);if(hCom=(HANDLE)-1)printf("打開COM失敗!n");return FALSE;elseprintf("COM打開成功!n");SetupComm(hCom,1024,1024); /輸入緩沖區(qū)和輸出緩沖區(qū)的大小都是1024COMMTIMEOUTS TimeOuts;/設定讀超時TimeOut
5、s.ReadIntervalTimeout=1000;TimeOuts.ReadTotalTimeoutMultiplier=500;TimeOuts.ReadTotalTimeoutConstant=5000;/設定寫超時TimeOuts.WriteTotalTimeoutMultiplier=500;TimeOuts.WriteTotalTimeoutConstant=2000;SetCommTimeouts(hCom,&TimeOuts); /設置超時DCB dcb;GetCommState(hCom,&dcb);dcb.BaudRate=9600;&
6、#160;/波特率為9600dcb.ByteSize=8; /每個字節(jié)有8位dcb.Parity=NOPARITY; /無奇偶校驗位dcb.StopBits=ONE5STOPBITS; /兩個停止位SetCommState(hCom,&dcb);DWORD wCount;/讀取的字節(jié)數(shù)BOOL bReadStat;while(1)PurgeComm(hCom,PURGE_TXCLEAR|PURGE_RXCLEAR); /清空緩沖區(qū)char str9=0;printf("%sn",str);bRea
7、dStat=ReadFile(hCom,str,9,&wCount,NULL);if(!bReadStat)printf("讀串口失敗!");return FALSE;elsestr8='0'printf("%sn",str);Sleep(100);(4) 了解在上位機(PC端)端,JAVA程序中如何調(diào)用串口?答:public static void process() try Enumeration portList = CommPortIdentifier.getPortIdentifiers(); while (p
8、ortList.hasMoreElements() CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() = CommPortIdentifier.PORT_SERIAL)/如果端口類型是串口則判斷名稱 if(portId.getName().equals("COM1")/如果是COM1端口則退出循環(huán) break; else portId=null; SerialPort serialPort = (SerialPort)portId
9、.open("Serial_Communication", 1000);/打開串口的超時時間為1000ms serialPort.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);/設置串口速率為9600,數(shù)據(jù)位8位,停止位1們,奇偶校驗無 InputStream in = serialPort.getInputStream();/得到輸入流 OutputStream out = serialPort.getOutputStream();/
10、得到輸出流 /進行輸入輸出操作/操作結束后 in.close(); out.close(); serialPort.close();/關閉串口 catch (PortInUseException e) e.printStackTrace(); catch (UnsupportedCommOperationException e) e.printStackTrace(); catch (IOException e) e.printStackTrace(); 2、 實驗目的和效果實驗目的:(1)學習、理解、掌握利用串口實現(xiàn)上位機和下位機之間的通訊(數(shù)據(jù)上傳和控制)。達到實驗要求,拓展二未實現(xiàn)。實驗
11、效果:3、 實驗內(nèi)容和步驟實驗內(nèi)容:(1) 默認在在OLED屏幕上分行顯示串口號、波特率、數(shù)據(jù)位、校驗位、停止位、“E”鍵發(fā)送模式、“F”鍵接收模式。思路:E鍵發(fā)送模式設置send=1 receive=0 F鍵接受模式設置 send=0 receive=1(2) 按下小鍵盤的“E”鍵,表示下位機(實驗箱)往上位機(PC)發(fā)送數(shù)據(jù),上位機開啟“超級終端”,下位機循環(huán)往上位機發(fā)送“0”“1”“2”。“9”字符,上位機在“超級終端”中可以看到。思路:定義一個全局變量字符數(shù)組,char rxchar2;GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,GPIO_PIN_
12、0);SysCtlDelay();UARTSend(unsigned char *)&rxchar, 1);SysCtlDelay();GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,0);rxchar0值不斷由0x30-0x39之間進行變化。if(rxchar0 >= 0x39) | (rxchar0 < 0x30)rxchar0 = 0x30;elserxchar0+;(3) 按下小鍵盤的“F”鍵,表示上位機(PC)往下位機(實驗箱)發(fā)送數(shù)據(jù),上位機開啟“超級終端”,輸入“A”、“B”、“C”、“D”等,下位機接受數(shù)據(jù),和小鍵盤輸入一樣
13、進行相應顯示。思路:if(UARTCharsAvail(UART0_BASE)rxchar0 = UARTCharGet(UART0_BASE); / 等待接收字符rxchar1 = '0'GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,GPIO_PIN_0);RIT128x96x4StringDraw("Receive: ", 12,80, 15); RIT128x96x4StringDraw(rxchar, 66,80,15);RIT128x96x4StringDraw(" ", 72,80,15);
14、 SysCtlDelay();GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,0);(4) 擴展:按照狀態(tài)機模式修改程序。思路:根據(jù)按鍵的不同判斷狀態(tài),三種狀態(tài),空閑,接收,發(fā)送。根據(jù)狀態(tài)的不同調(diào)用相應的方法。(5) 擴展:在另外一片CPU LM3S 2110上實現(xiàn)串口通信,接實驗箱第二個串口接口,因為這一片CPU不帶顯示器,可以只實現(xiàn)下位機(實驗箱)往上位機(PC)發(fā)送數(shù)據(jù),上位機開啟“超級終端”,下位機循環(huán)往上位機發(fā)送“0”“1”“2”?!?”字符,上位機在“超級終端”中可以看到。思路:理論上在創(chuàng)建項目時選擇cpu LM3S 2110,改變實驗箱上連線,連
15、接UART2的串口即可實現(xiàn)。但實際操作中并未實現(xiàn)。實驗步驟:(1) 加載必要程序(2) 串口啟動配置(main)(3) 增加串口相關函數(shù)(main.c中)(4) 修改主函數(shù),實現(xiàn)本次實驗要求的功能(5) 編譯、連接,生成可執(zhí)行程序文件(6) 反復(3)-(5)步驟,直到完成(7) 硬件連接,連接標志UART1的串口(8) 聯(lián)調(diào)4、 實驗總結與收獲實驗代碼#include <stdio.h>#include <LM3Sxxxx.H>#include <hw_ints.h>#include <hw_memmap.h>#include <hw_t
16、ypes.h>#include <gpio.h>#include <interrupt.h>#include <sysctl.h>#include <uart.h>#include "rit128x96x4.h" /#include "utility.h" #define MAX_SIZE 40 / 緩沖區(qū)最大限制長度#define UARTCharGetNB UARTCharGetNonBlockingchar RxBuf1 + MAX_SIZE; / 接收緩沖區(qū)int BufP = 0; / 緩沖
17、區(qū)位置變量tBoolean RxEndFlag = false; / 接收結束標志unsigned int Event=0,Event_key=0,Send=0,Receive=0;int type=0;int ki=0;char oledkey2;int state=0;unsigned char ucValue=0x00;long time=0;int Speed,count=0;unsigned char rxchar10;void timerset(void);void UARTSend(const unsigned char *pucBuffer, unsigned long ulC
18、ount);void recive()if(UARTCharsAvail(UART0_BASE)rxchar0 = UARTCharGet(UART0_BASE); / 等待接收字符rxchar1 = '0'GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,GPIO_PIN_0);RIT128x96x4StringDraw("Receive: ", 30,80, 15);RIT128x96x4StringDraw(rxchar, 66,80,15);RIT128x96x4StringDraw(" ", 72
19、,80,15);SysCtlDelay();GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,0);void send() RIT128x96x4StringDraw("sending1",0,60,15);GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,GPIO_PIN_0);SysCtlDelay();/RIT128x96x4StringDraw("sending2",20,1,15);UARTSend(unsigned char *)&rxchar, 1);SysCtlDel
20、ay();GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,0);if(rxchar0 >= 0x39) | (rxchar0 < 0x30)rxchar0 = 0x30;elserxchar0+;RIT128x96x4StringDraw("sended ",1,1,15);int main()/聲明部分rxchar0=0x30;rxchar1='0'/初始化/* Set the clocking to run from PLL at 50 MHz */SysCtlClockSet(SYSCTL_SYSDIV_1
21、 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);RIT128x96x4Init();RIT128x96x4Clear();/設置時鐘中斷1SysTickPeriodSet(SysCtlClockGet()/100); SysTickEnable();SysTickIntEnable();/*/設置鍵盤中斷/*使能外設GPIO */SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);SysCtlPeripher
22、alEnable(SYSCTL_PERIPH_GPIOD);SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);/*設置GPIO 為輸入 */GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_7);GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_4);/*配置GPIO 端口為輸出/ 7segd1(
23、PB6);7segd2(PB4);7segd3(PB5)GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6);/ bitcode0(PC5);bitcode1(PC6);bitcode2(PC7)GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);/ 7segd0(PD4);7segdot(PD5);rst(PD6)GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, G
24、PIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6);*/*使能中斷 */IntEnable(INT_GPIOD);IntMasterEnable();GPIOPinIntEnable(GPIO_PORTD_BASE, GPIO_PIN_7);GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_7, GPIO_RISING_EDGE);/*GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PI
25、N_1);/ Configure the UART for 115,200, 8N1 operation.UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), ,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE);UARTFIFOLevelSet(UART0_BASE, / 設置發(fā)送和接收FIFO 深度UART_FIFO_TX4_8,UART_FIFO_RX6_8);IntEnable(INT_UART0);UARTIntEnable(UART0_BASE, UART_
26、INT_RX | UART_INT_RT);timerset();/計時器初始化timerset();/計時器初始化 RIT128x96x4StringDraw("com1", 0, 0, 15);/顯示串口號RIT128x96x4StringDraw("", 0, 20, 15);/顯示波特率/*unsigned char a= *pulConfig;char d30;char b30;d=*a+1;b=*a+2;*/RIT128x96x4StringDraw("8", 0, 40, 15);/顯示數(shù)據(jù)位/unsigned long
27、 parity=UARTParityModeGet(UART0_BASE);/sprintf(p,"%d",parity );RIT128x96x4StringDraw("wu", 0, 60, 15);/顯示校驗位RIT128x96x4StringDraw("1", 0, 80, 15);/顯示停止位RIT128x96x4StringDraw("E:send",1,31,15);RIT128x96x4StringDraw("F:receiave",1,41,15);while(1) if(Ev
28、ent)Event = 0; if(Event_key)Event_key = 0;switch(oledkey0)/*case '0':Draw_Char_H(0);break;case '1':Reset_Counter_Speed(128);Speed = 128;break;*/case 'F': state=1;/Receive = 1;/Send = 0;break;case 'E': state=2;/Send = 1;/Receive = 0;break;default:state=0;break; switch(
29、state)case 0:break;case 1: recive();break;case 2:send();break;default:/state=0;break; /*if(Send)RIT128x96x4StringDraw("sending1",0,60,15);GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,GPIO_PIN_0);SysCtlDelay();/RIT128x96x4StringDraw("sending2",20,1,15);UARTSend(unsigned char *)&rx
30、char, 1);SysCtlDelay();GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,0);if(rxchar0 >= 0x39) | (rxchar0 < 0x30)rxchar0 = 0x30;elserxchar0+;RIT128x96x4StringDraw("sended ",1,1,15);if(Receive) if(UARTCharsAvail(UART0_BASE)rxchar0 = UARTCharGet(UART0_BASE); / 等待接收字符rxchar1 = '0'GPIOPi
31、nWrite(GPIO_PORTF_BASE, GPIO_PIN_0,GPIO_PIN_0);RIT128x96x4StringDraw("Receive: ", 30,80, 15);RIT128x96x4StringDraw(rxchar, 66,80,15);RIT128x96x4StringDraw(" ", 72,80,15);SysCtlDelay();GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,0);*/return 0;/中斷處理void SysTick_Handler (void) Event =
32、1;/*中斷服務函數(shù)ISR*/void GPIO_PORT_D_ISR(void)unsigned char ucKey;unsigned long ulStatus;ulStatus = GPIOPinIntStatus(GPIO_PORTD_BASE, true);GPIOPinIntClear(GPIO_PORTD_BASE, ulStatus);if(ulStatus & GPIO_PIN_7)ucKey = GPIOPinRead(GPIO_PORTC_BASE, GPIO_PIN_4);ucKey = ucKey>>1;ucValue = ucValue + u
33、cKey;ucValue = ucValue<<1;ki+;if(ki=4)ki=0;oledkey1='0'if(ucValue>>4)<10)oledkey0 = (ucValue>>4) + 48;elseoledkey0 = (ucValue>>4) - 10 + 'A' Event_key = 1;void timerset()SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);TimerConfigure(TIMER0_BASE, TIMER_CFG_32_B
34、IT_PER);TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/100); / 不除以100 則1 秒中斷一次IntEnable(INT_TIMER0A);TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);void Timer0IntHandler(void)unsigned long ulStatus;ulStatus = TimerIntStatus(TIMER0_BASE, true); / 獲取當前中斷狀態(tài)TimerIntClear(TIMER0_BASE, TIMER_TIMA_TI
35、MEOUT); / 清除全部中斷狀態(tài)if (ulStatus & TIMER_TIMA_TIMEOUT) / 如果是超時中斷/補充該部分代碼time+;/每次計時中斷,相應計數(shù)值進行變化void UARTIntHandler(void)unsigned long uStatus;/ Get the interrrupt status.uStatus = UARTIntStatus(UART0_BASE, true);/ Clear the asserted interrupts.UARTIntClear(UART0_BASE, uStatus);/ Loop while there a
36、re characters in the receive FIFO.while(UARTCharsAvail(UART0_BASE)/ Read the next character from the UART and write it back to the UART.UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE); void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)/ Loop while there are mo
37、re characters to send./while(ulCount-)/ Write the next character to the UART./UARTCharPutNonBlocking(UART0_BASE, *pucBuffer+);拓展#include <stdio.h>#include <LM3Sxxxx.H>#include <hw_ints.h>#include <hw_memmap.h>#include <hw_types.h>#include <gpio.h>#include <inte
38、rrupt.h>#include <sysctl.h>#include <uart.h>#include "rit128x96x4.h" /#include "utility.h" #define MAX_SIZE 40 / 緩沖區(qū)最大限制長度#define UARTCharGetNB UARTCharGetNonBlockingchar RxBuf1 + MAX_SIZE; / 接收緩沖區(qū)int BufP = 0; / 緩沖區(qū)位置變量tBoolean RxEndFlag = false; / 接收結束標志unsigned
39、int Event=0,Event_key=0,Send=0,Receive=0;int type=0;int ki=0;char oledkey2;int state=0;unsigned char ucValue=0x00;long time=0;int Speed,count=0;unsigned char rxchar10;void timerset(void);void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount);void recive()if(UARTCharsAvail(UART0_BASE)rx
40、char0 = UARTCharGet(UART0_BASE); / 等待接收字符rxchar1 = '0'GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,GPIO_PIN_0);RIT128x96x4StringDraw("Receive: ", 30,80, 15);RIT128x96x4StringDraw(rxchar, 66,80,15);RIT128x96x4StringDraw(" ", 72,80,15);SysCtlDelay();GPIOPinWrite(GPIO_PORTF_BASE
41、, GPIO_PIN_0,0);void send() RIT128x96x4StringDraw("sending1",0,60,15);GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,GPIO_PIN_0);SysCtlDelay();/RIT128x96x4StringDraw("sending2",20,1,15);UARTSend(unsigned char *)&rxchar, 1);SysCtlDelay();GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,0);i
42、f(rxchar0 >= 0x39) | (rxchar0 < 0x30)rxchar0 = 0x30;elserxchar0+;RIT128x96x4StringDraw("sended ",1,1,15);int main()/聲明部分rxchar0=0x30;rxchar1='0'/初始化/* Set the clocking to run from PLL at 50 MHz */SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_
43、8MHZ);RIT128x96x4Init();RIT128x96x4Clear();/設置時鐘中斷1SysTickPeriodSet(SysCtlClockGet()/100); SysTickEnable();SysTickIntEnable();/*/設置鍵盤中斷/*使能外設GPIO */SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);SysCtlPeripheralEnab
44、le(SYSCTL_PERIPH_UART0);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);/*設置GPIO 為輸入 */GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_7);GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_4);/*配置GPIO 端口為輸出/ 7segd1(PB6);7segd2(PB4);7segd3(PB5)GPIOPinTypeGPIOOutput(
45、GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6);/ bitcode0(PC5);bitcode1(PC6);bitcode2(PC7)GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);/ 7segd0(PD4);7segdot(PD5);rst(PD6)GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6);*/*使能中斷 */Int
46、Enable(INT_GPIOD);IntMasterEnable();GPIOPinIntEnable(GPIO_PORTD_BASE, GPIO_PIN_7);GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_7, GPIO_RISING_EDGE);/*GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);/ Configure the UART for 115,200, 8N1 operati
47、on.UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), ,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE);UARTFIFOLevelSet(UART0_BASE, / 設置發(fā)送和接收FIFO 深度UART_FIFO_TX4_8,UART_FIFO_RX6_8);IntEnable(INT_UART0);UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);timerset();/計時器初始化timerset()
48、;/計時器初始化 RIT128x96x4StringDraw("com1", 0, 0, 15);/顯示串口號RIT128x96x4StringDraw("", 0, 20, 15);/顯示波特率/*unsigned char a= *pulConfig;char d30;char b30;d=*a+1;b=*a+2;*/RIT128x96x4StringDraw("8", 0, 40, 15);/顯示數(shù)據(jù)位/unsigned long parity=UARTParityModeGet(UART0_BASE);/sprintf(p,&
49、quot;%d",parity );RIT128x96x4StringDraw("wu", 0, 60, 15);/顯示校驗位RIT128x96x4StringDraw("1", 0, 80, 15);/顯示停止位RIT128x96x4StringDraw("E:send",1,31,15);RIT128x96x4StringDraw("F:receiave",1,41,15);while(1) if(Event)Event = 0; if(Event_key)Event_key = 0;switch(o
50、ledkey0)/*case '0':Draw_Char_H(0);break;case '1':Reset_Counter_Speed(128);Speed = 128;break;*/case 'F': state=1;/Receive = 1;/Send = 0;break;case 'E': state=2;/Send = 1;/Receive = 0;break;default:state=0;break; switch(state)case 0:break;case 1: recive();break;fffhhcas
51、e 2:send();break;default:/state=0;break; /*if(Send)RIT128x96x4StringDraw("sending1",0,60,15);GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,GPIO_PIN_0);SysCtlDelay();/RIT128x96x4StringDraw("sending2",20,1,15);UARTSend(unsigned char *)&rxchar, 1);SysCtlDelay();GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0,0);if(rxchar0 >= 0x39) | (rxchar0 < 0x30)rxchar0 = 0x30;elserxchar0+;RIT128x96x4StringDraw("sended ",1,1,15);if(Receive) if(UARTCharsAvail(UART0_BASE)rxchar0 = UARTCharGet(UART0_BASE); / 等待接收字符rxchar1 = '0'GPIOPinWrite(GPIO_PORTF_B
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2023六年級英語下冊 Review Module Unit 2說課稿 外研版(三起)001
- 2025合同模板銷售事務處理制度A范本
- 2023三年級英語下冊 Unit 4 Food and Restaurants Lesson 23 How Much Are They說課稿 冀教版(三起)001
- 3 植物長在哪里 說課稿-2024-2025學年科學一年級上冊教科版
- 15分享真快樂(說課稿)-部編版道德與法治一年級下冊001
- 養(yǎng)老護工合同范本
- Unit2 Morals and virtues Reading for writing說課稿-2023-2024學年人教版高中英語必修第三冊
- 1 觀潮說課稿-2024-2025學年四年級上冊語文統(tǒng)編版
- 2024年五年級英語上冊 Module 2 Unit 2 How much cheese did you buy說課稿 外研版(三起)
- 路面挖補施工方案
- 浙江省名校新2025屆高一數(shù)學第一學期期末達標檢測試題含解析
- 學習2024《關于加強社會組織規(guī)范化建設推動社會組織高質(zhì)量發(fā)展的意見》解讀課件
- 2024年縣全民健身活動狀況調(diào)查活動方案
- 足球場建設項目設計方案
- 兒童四宮格數(shù)獨96題-(由簡到難,支持打印)
- 湖北宜昌歷年中考語文現(xiàn)代文之記敘文閱讀16篇(含答案)(2003-2023)
- 問題探究如何讓城市不再看海(教學課件)高一地理
- 2024年人教版五年級數(shù)學(上冊)模擬考卷及答案(各版本)
- 人教版八年級下冊歷史第1課 中華人民共和國成立 說課稿
- 2024-2030年傷口護理管理行業(yè)市場現(xiàn)狀供需分析及重點企業(yè)投資評估規(guī)劃分析研究分析報告
- 《地球物理勘查》全冊配套完整教學課件
評論
0/150
提交評論