ARM7学习笔记---ClimberWin
ART0_INT(void)
{ unsigned short int U0DL;
U0LCR = 0x83; // DLAB = 1,可设置波特率 ;无奇偶校验 1位停止位 8位数据长度。
U0DL = (PCLK/16)/baudrate;
U0DLM= U0DL/256; //高8位
U0DLL = U0DL%256; //低8位
U0LCR = 0x03; // DLAB = 0,设置好波特率;无奇偶校验 1位停止位 8位数据长度。
}
/***********串口发送字节**********************/
void UART0_SendByte(unsigned char da
{
U0THR = da
while( PE==0 ); //等待数据发送完毕 PE=1忙碌;PE=0;不忙绿
}
/***********串口发送字符串**********************/
void UART0_SendStr(unsigned char const *str)
{ while(1)
{ if( *str == \0 ) break;
UART0_SendByte(*str++); //发送数据
}
}
/////////////主程序///////////////////
int main(void)
{
PINSEL0 = 0x00000005; //设置I/O连接到UART0
PINSEL1 = 0x00000000;
UART0_INT(); //串口初始化
while(1)
{
UART0_SendStr("LPC2103 UART0 Test OK!"); //向串口发送字符串
delayms(1000);
}
return(0);}
2009年12月4日星期五
学习LCD12864控制,从AVR程序上移植过来
调试成功,但是中间遇到了一些问题,一直没找出原因,原来是一个时序问题,在AVR上是正常的,在LPC2103上就有问题,是时序原因。
IO0SET=LCD_SCLK;
DELAY(100); //这个延时程序原本没加,所以出错了,加上去就正常了
IO0CLR=LCD_SCLK;LCD12864移植成功。2009年12.4.16:00
LCD12864液晶显示源程序:
/**************ARM7(LPC2103)练习程序**************************/
/*************************************************************/
/*****File Function : LCD12864显示 *****/
/*****Program Author : ZhengWen(ClimberWin) *****/
/*****MCU : LPC2103F 外部11.0592M晶振 *****/
/*****Compile Date : 2009/12/4 *****/
/*****Edition Info : V1.0 *****/
/*************************************************************/
//编译环境 KEIL for ARM
//功能描述:LCD12864显示程序
#include
#include
#define uint unsigned int
#define uchar unsigned char
#define LCD_CS (1<0) //片选 高电平有效 单片LCD使用时可固定高电平 rs
#define LCD_SID (1<1) //数据 r/w
#define LCD_SCLK (1<2) //时钟 e
uchar const HEX_[]={"0123456789ABCDEF"};
uchar BUFFER[6] = {0};
uchar K_NUM;
void DELAY(uchar t);
void LCD_SEND(uchar date);
void LCD_SCOM(uchar st,uchar date);
void LCD_DELAY(void);
void LCD_INIT(void);
void LCD_write(uchar *p);
void LCD_LOCAL(uchar x,uchar y,uchar *p);
void LCD_cblank(uchar x,uchar y);
void LCD_count(long s,uchar x1,uchar y1,uchar x,uchar y,uchar *p);
void LCD_bai();
void Delay1ms(unsigned int count);
/*************延时程序***************/
void delayms(unsigned int count)
{
unsigned int i,j;
for(i=0;i for(j=0;j<5000;j++); } void Delay1ms(unsigned int count) { unsigned int i,j; for(i=0;i for(j=0;j<120;j++); } void DELAY(uchar t) { while(--t); } void LCD_SEND(uchar date) { uchar i; //LCD_SCLK=0; IO0CLR=LCD_SCLK; for(i=0;i<8;i++) { //LCD_SID=date&0x80; if((date&0x80)==0) {IO0CLR=LCD_SID;} else { IO0SET=LCD_SID;} //LCD_SCLK=1; //LCD_SCLK=0; IO0SET=LCD_SCLK; DELAY(100); IO0CLR=LCD_SCLK; date<=1; } } void LCD_SCOM(uchar st,uchar date) { uchar st_temp,hdate,ldate; if(st) st_temp=0xfa; else st_temp=0xf8; hdate=date&0xf0; ldate=date&0x0f; ldate <= 4; // LCD_CS = 1; IO0SET=LCD_CS; LCD_SEND(st_temp); LCD_SEND(hdate); LCD_SEND(ldate); //LCD_CS = 0; IO0CLR=LCD_CS; DELAY(38); } void LCD_DELAY(void) { uchar s; s=10; while(--s) DELAY(250); } void LCD_INIT(void) { LCD_SCOM(0,0x30); LCD_DELAY(); LCD_SCOM(0,0x0c); LCD_DELAY(); LCD_SCOM(0,0x01); //清屏,将DDRAM的地址计数器归零 LCD_DELAY(); } void LCD_write(uchar *p) { while(*p) { LCD_SCOM(1,*p); p++; } } void LCD_LOCAL(uchar x,uchar y,uchar *p) //lcd string (x,y) write! { switch (x) { case 1:LCD_SCOM(0,0x7f+y); LCD_write(p);break; case 2:LCD_SCOM(0,0x8f+y); LCD_write(p);break; case 3:LCD_SCOM(0,0x87+y); LCD_write(p);break; case 4:LCD_SCOM(0,0x97+y); LCD_write(p);break; default :LCD_SCOM(0,0x7f+y); LCD_write(p); } } void LCD_cblank(uchar x,uchar y) { switch (x) { case 1:LCD_SCOM(0,0x7f+y); LCD_SCOM(0,0x0d);break; case
ARM7ClimberWi 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)