ARM7入门6,LCD显示字符

用ADS1.2编辑的 , 注意添加target.c , IRQ.s , Startuo.s和mem.scf文件 。
主程序:
/****************************************************************************
* File: main.c
* 功能:向LCD输出字符
****************************************************************************/
#include "config.h"
#define rs (1<<8)
#define rw (1<<9)
#define en (1<<10)
#define busy (1<<7)
uint8 txt0[]={"An ARM7 example"};
uint8 txt1[]={"By IMU"};
uint8 txt2[]={" 2008-09-13"};
/****************************************************************************
* 名称:ChkBusy()
* 功能:检查总线是否忙
****************************************************************************/
void ChkBusy()
{
IO0DIR=0x700;
while(1)
{
IO0CLR=rs;
IO0SET=rw;
IO0SET=en;
if(!(IO0PIN & busy))break;
IO0CLR=en;
}
IO0DIR=0x7ff;
}
/****************************************************************************
* 名称:WrOp()
* 功能:写函数
****************************************************************************/
void WrOp(uint8 dat)
{
ChkBusy();
IO0CLR=rs;//全部清零
IO0CLR=rw;
IO0CLR=0xff;//先清零
IO0SET=dat;//再送数
IO0SET=en;
IO0CLR=en;
}
/****************************************************************************
* 名称:WrDat()
* 功能:写数据函数
****************************************************************************/
void WrDat(uint8 dat)
{
ChkBusy();
IO0SET=rs;
IO0CLR=rw;
IO0CLR=0xff;//先清零
IO0SET=dat;//再送数
IO0SET=en;
IO0CLR=en;
}
/****************************************************************************
* 名称:lcd_init()
* 功能:lcd初始化函数
****************************************************************************/
void lcd_init(void)
{
WrOp(0x38);
WrOp(0x06);//光标加1
WrOp(0x0c);//开显示
}
/****************************************************************************
* 名称:DisText()
* 功能:显示文本函数
****************************************************************************/
void DisText(uint8 addr,uint8 *p)
{
WrOp(addr);
while(*p !='')WrDat(*(p++));
}
【ARM7入门6,LCD显示字符】/****************************************************************************
* 名称:main()
* 功能:显示文本
****************************************************************************/
int main(void)
{
lcd_init();
IO0DIR=0x7ff;//设置为输出
IO0CLR=0x7ff;
DisText(0x80,txt0);
DisText(0xc0,txt1);
DisText(0xc6,txt2);
while(1);
}

    推荐阅读