新聞中心

ARM7學習---GPS練習

作者: 時間:2016-11-18 來源:網(wǎng)絡(luò) 收藏
下午抽了點時間在調(diào)試ARM7,想把上次用ATMEGA8做的GPS移植到ARM7上去,下午移植了LCD和串口,但是還沒把串口中斷程序編寫好。按鍵也還沒移植,其他OK了,再花點時間就可以完整了。我想GPS和GSM結(jié)合起來,這樣可以做個比較實用的東西。自己玩玩很不錯!哈哈!再接再厲繼續(xù)努力......

本文引用地址:http://butianyuan.cn/article/201611/316018.htm

/**************ARM7(LPC2103)練習程序**************************/
/*************************************************************/
/*****File Function : lcd10265液晶顯示程序 *****/
/*****Program Author : ZhengWen(ClimberWin) *****/
/*****MCU : LPC2103F 外部11.0592M晶振 *****/
/*****Compile Date : 2010/01/13 *****/
/*****Edition Info : V1.0 *****/
/*************************************************************/
//編譯環(huán)境 KEIL for ARM
//修改時間2010年2月9日,能夠串口輸出數(shù)據(jù),接收數(shù)據(jù),并且LCD上顯示
/*************************************************************/
//修改時間2010年2月10日
//修改內(nèi)容:一直串口和LCD顯示不能同時用,后來發(fā)現(xiàn)是設(shè)置好PLL后由于時序太快,導致液晶不能顯示
// 調(diào)整好時序后液晶可以正常顯示。
//LCD GUI移植成功,還需要移植按鍵
//#include
//#include
#include "RCU6093.h"
#include "win_delay.h"
#include "GPS_GH_80.h"
#define uchar unsigned char
#define uint unsigned int
#define baudrate 9600 //設(shè)置波特率
#define PE (U0LSR&0x40)//定義串口數(shù)據(jù)發(fā)送忙碌與否,PE=1忙碌;PE=0;不忙綠

#define Fosc(11059200)//晶振頻率,10MHz~25MHz,應(yīng)當與實際一至
#define Fcclk(Fosc * 6) //66.3552 系統(tǒng)頻率,必須為Fosc的整數(shù)倍(1~32),且<=60MHZ
#define Fcco(Fcclk * 4) //CCO頻率,必須為Fcclk的2、4、8、16倍,范圍為156MHz~320MHz
#define Fpclk(Fcclk / 4) * 1 //016.5888,VPB時鐘頻率,只能為(Fcclk / 4)的1 ~ 4倍

//常量定義
uchar lcd_y_num=0;//液晶顯示Y軸坐標
uchar temp_h;
uchar temp_l;
uchar stop=0;

uchar UART_MID;//定義一個緩存區(qū)數(shù)據(jù)臨時存儲地址

uchar numh=0;
uchar numl=0;

uchar flag=0;
uchar temp1;

uchar data_num0=1;
uchar data_num1=1;

uchar key1_flag; //定義按鍵標志位
uchar key2_flag;
uchar key3_flag;
uchar gps_flag;//定義是否有GPS數(shù)據(jù)


//////////////////////////////////////////////////////////////
void LCD_PORT_INI(void);
void LCD_write_LCD(unsigned char data,unsigned char cmd);
void LCD_RCU6093_Clear(void);
void LCD_RCU6093_tset(void);
void LCD_RCU6093_int(void);

void init_USART(void);//USART 初始化
void write_asicc(uchar assi);
void LCD_xy(uchar x,uchar y);
void write_hanzi(uchar hz);
void write_hanzi16(uchar hz,uchar x,uchar y,uchar mirror);
void PLL_Init(void);

void UART0_INT(void); //串口初始化
void UART0_SendByte(unsigned char data); //串口發(fā)送字節(jié)
void UART0_SendStr(unsigned char const *str);//串口發(fā)送字符串

void keytest(void); //按鍵測試程序

void Charge(void);//電池充電子程序
void Signal_strength(void);//信號強度指示程序
void banbenxinxi(void);//顯示版本信息
void GPS_display(void);
/**********************************************/


void keytest(void) //按鍵測試程序
{

}
////////////充電狀態(tài)////////////////////

void Charge(void)
{
uchar i;
LCD_xy(94,1);//LCD指針坐標
write_hanzi(19);//
for(i=0;i<6;i++)
{ LCD_xy(94,0);//LCD指針坐標
write_hanzi(13+i);//
delayms(60000);
delayms(60000);
delayms(60000);
}
}

///////////信號強度狀態(tài)//////////////////
void Signal_strength(void)
{
uchar i;
LCD_xy(0,1);//LCD指針坐標
write_hanzi(20);//
for(i=0;i<4;i++)
{ LCD_xy(0,0);//LCD指針坐標
write_hanzi(21+i);//
delayms(60000);
delayms(60000);
delayms(60000);
}
}

///////////////////////////////
/////////////////////////////////
void banbenxinxi(void)
{
LCD_RCU6093_int(); //初始化液晶

LCD_xy(0,2);//LCD指針坐標

write_asicc(G);
write_asicc(P);
write_asicc(S);
write_asicc(0);
write_asicc(V);
write_asicc(1);
write_asicc(.);
write_asicc(2);


LCD_xy(0,3);//LCD指針坐標
write_asicc(C);
write_asicc(P);
write_asicc(U);
write_asicc(:);

write_asicc(A);
write_asicc(R);
write_asicc(M);
write_asicc(7);
write_asicc(T);
write_asicc(D);
write_asicc(M);
write_asicc(I);

LCD_xy(0,4);//LCD指針坐標
write_asicc(B);
write_asicc(Y);
write_asicc(0);
write_asicc(C);
write_asicc(L);
write_asicc(I);
write_asicc(M);
write_asicc(B);
write_asicc(E);
write_asicc(R);
write_asicc(W);
write_asicc(I);
write_asicc(N);
LCD_xy(0,5);//LCD指針坐標
write_asicc(2);
write_asicc(0);
write_asicc(1);
write_asicc(0);
write_hanzi(4);//年
write_asicc(0);
write_asicc(2);
write_hanzi(5);//月
write_asicc(1);
write_asicc(0);
write_hanzi(6);//日

LCD_xy(72,7);//LCD指針坐標
write_asicc(B);
write_asicc(A);
write_asicc(C);
write_asicc(K);
//////////顯示手持式導航儀/////////////////
write_hanzi16(4,4,0,0);
write_hanzi16(5,1*16+4,0,0);
write_hanzi16(6,2*16+4,0,0);
write_hanzi16(7,3*16+4,0,0);
write_hanzi16(8,4*16+4,0,0);
write_hanzi16(9,5*16+4,0,0);

}


void PLL_Init(void)
{
/* 設(shè)置系統(tǒng)各部分時鐘 */
PLLCON = 1;
#if ((Fcclk / 4) / Fpclk) == 1
VPBDIV = 0;
#endif
#if ((Fcclk / 4) / Fpclk) == 2
VPBDIV = 2;
#endif
#if ((Fcclk / 4) / Fpclk) == 4
VPBDIV = 1;
#endif
#if (Fcco / Fcclk) == 2
PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5);
#endif
#if (Fcco / Fcclk) == 4
PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5);
#endif
#if (Fcco / Fcclk) == 8
PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5);
#endif
#if (Fcco / Fcclk) == 16
PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5);
#endif
PLLFEED = 0xaa;
PLLFEED = 0x55;
while((PLLSTAT & (1 << 10)) == 0);
PLLCON = 3;
PLLFEED = 0xaa;
PLLFEED = 0x55;
}

/***********串口0初始化**********************/
void UART0_INT(void)
{ unsigned int U0DL;

U0LCR = 0x83; // DLAB = 1,可設(shè)置波特率;無奇偶校驗 1位停止位 8位數(shù)據(jù)長度。
U0DL = (Fpclk/16)/baudrate;
U0DLM= U0DL/256; //高8位
U0DLL = U0DL%256; //低8位
U0LCR = 0x03; // DLAB = 0,設(shè)置好波特率;無奇偶校驗 1位停止位 8位數(shù)據(jù)長度。
}
/***********串口發(fā)送字節(jié)**********************/
void UART0_SendByte(unsigned char data)
{
U0THR = data; //發(fā)送數(shù)據(jù)
while( PE==0 ); //等待數(shù)據(jù)發(fā)送完畢 PE=1忙碌;PE=0;不忙綠

}
/***********串口發(fā)送字符串**********************/
void UART0_SendStr(unsigned char const *str)
{ while(1)
{ if( *str ==