當前位置:編程學習大全網 - 源碼下載 - 求C語言編寫的通過電腦串口用串口助手接收GPS的程序

求C語言編寫的通過電腦串口用串口助手接收GPS的程序

///////////////////////////////////////////////////////////

//

設計題目

:

基於51單片機的串口通信

//

功能

:

//

說明

:

晶振用12m,

///////////////////////////////////////////////////////////

#include

//

12m

晶振

#define

uchar

unsigned

char

#define

uint

unsigned

int

///////////////////////////////////////////////////////////

//

name

:

串口發送函數

//

in

:

//

out

:

//

function

:

//

explain

:

///////////////////////////////////////////////////////////

void

send(uchar

x)

{

sbuf=x;

//

將數據放到緩沖區,發送

while(!ti);

//

等待發送完成

ti=0;

//

清標誌位

}

///////////////////////////////////////////////////////////

//

name

:

初始化函數

//

in

:

//

out

:

//

function

:

//

explain

:

///////////////////////////////////////////////////////////

void

init(void)

{

tmod=0x20;

//

t1工作在方式2,自動重載

th1=0xe6;

tl1=0xe6;

//

設置波特率為1200

sm0=0;

sm1=1;

//

串口方式1

tr1=1;

//

打開定時器1

}

///////////////////////////////////////////////////////////

//

name

:

主函數

//

in

:

//

out

:

//

function

:

//

explain

:

///////////////////////////////////////////////////////////

void

main(void)

{

uchar

i;

init();

//

初始化

while(1)

{

for(i=0;

i<10;

i++)

{

send(i);

}

}

}

  • 上一篇:GPS監控調度系統的功能方案
  • 下一篇:小學科學知識競賽111題
  • copyright 2024編程學習大全網