#include "config.h"
#include "delay.h"
#define LCM_RS 1 << 2
#define LCM_RW 1 << 11
#define LCM_EN 1 << 12
//uint8 str0[]={"-Test frequency-"};
//uint8 str1[]={" F=00000 "};
//uchar code str2[]={" "};
/*******************************/
//=================================================//
/* 函数名:void WaitForEnable(void)
作用:检测忙碌信号 */
//================================================//
void WaitForEnable(void)
{
IO0DIR = (0x00<<15);
IO0DIR = LCM_RS | LCM_RW | LCM_EN;
IO0CLR = LCM_RS;
IO0SET = LCM_RW;
IO0SET = LCM_EN;
delay(10);
while(IO0PIN & (0x80<<15));
IO0CLR = LCM_EN;
}
//==========================================================//
/* 函数名:void WriteCommandLCM(uchar CMD,uchar Attribc)
作用: 写命令到LCM */
//==========================================================//
void WriteCommandLCM(uint8 CMD,uint8 Attribc)
{
if(Attribc)
{
WaitForEnable();
}
IO0DIR = (0xff<<15)|(0x01<<2)|(0x01<<12)|(0x01<<11);
IO0CLR = LCM_RS;
IO0CLR = LCM_RW;
IO0SET = LCM_EN;
// _nop_();
IO0SET = (CMD << 15);
// _nop_();
IO0SET = LCM_EN;
delay(10);
IO0CLR = LCM_EN;
delay(10);
}
//=========================================================//
/* 函数名: void WriteDataLCM(uchar dataW)
作用:写数据 */
//=========================================================//
void WriteDataLCM(uint8 dataW)
{
WaitForEnable();
IO0DIR = (0xff<<15)|(0x01<<2)|(0x01<<12)|(0x01<<11);
IO0SET = LCM_RS;
IO0CLR = LCM_RW;
IO0SET = LCM_EN;
//_nop_();
IO0SET = (dataW << 15);
//_nop_();
IO0SET = LCM_EN;
delay(10);
IO0CLR = LCM_EN;
delay(10);
}
//=========================================================//
/* 函数名: void InitLcd()
作用:LCM初始化 */
//=========================================================//
void InitLcd()
{
WriteCommandLCM(0x2c,0); //功能
delay(10);
WriteCommandLCM(0x06,0);//输出方式设置
delay(10);
WriteCommandLCM(0x01,0);//清屏
delay(10);
}
int main(void)
{
PINSEL0=0X00000000;
InitLcd(); //LCM初始化设置
WriteCommandLCM(0x80,0);
WriteDataLCM(0x30);
while(1);
return 0;
}
请问 为什么1602上还是一条黑 {MOD}的?哪里有错。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
调试过了 没什么错误,但1602上就显示一行黑 {MOD}的。
一周热门 更多>