各位高手帮忙分析下:CTLPORTC|= (Dat>>i)&0x01; 语句有问题吗?为什么我调试着感觉程序没有运行该语句呢?,完整程序如下:
#include "iom64v.h"
#include "LCD.H"
#include "MACROS.H"
//主控单片机型号Atmega64;
//晶振:内部晶振8MHz,程序烧写时选择合适的选项;
//时钟周期: T1=1/fosc=1/(8*10M);
uint cuont;
/*============================================
函数功能:延时函数
入口参数:无
返回参数:无
备 注:延时时间1ms
============================================*/
void Delay_1ms (uint cuont) //cuont=200,Delay=200ms
{
uint j;
for(;cuont>0;cuont--)
{
for(j=8000;j>0;j--)
{;}
}
}
/*============================================
函数功能:写ID
入口参数:ID号,模式
返回参数:无
备 注:写完ID后,写CMD,CS不能拉高
============================================*/
void Write_ID(uchar ID)
{
uchar i ;
/*
for(i=0;i<3;i++)
{
CLR_LCD_WR; // WR=0;
Delay_1ms(5);
CTLPORTC|=(ID>>i)&0x01;
Delay_1ms(5);
SET_LCD_WR;
Delay_1ms(5);
}
*/
CLR_LCD_WR; //WR=0;
Delay_1ms(2);
CTLPORTC|=(ID&0x04)>>2;
Delay_1ms(2);
SET_LCD_WR; //WR=1;
Delay_1ms(2);
CLR_LCD_WR; //WR=0;
Delay_1ms(2);
CTLPORTC|=(ID&0x02)>>1;
Delay_1ms(2);
SET_LCD_WR; //WR=1;
Delay_1ms(5);
CLR_LCD_WR; //WR=0;
Delay_1ms(2);
CTLPORTC|=ID&0x01;
Delay_1ms(2);
SET_LCD_WR; //WR=1;
Delay_1ms(2);
}
/*============================================
函数功能:写命令
入口参数:CMD:指令数据
返回参数:无
备 注:无
============================================*/
void Write_CMD(uchar CMD)
{
uchar i;
for(i=0;i<8;i++)
{
CLR_LCD_WR; //WR=0;
Delay_1ms(2);
CTLPORTC|=(CMD>>(7-i)) & 0x01;
Delay_1ms(2);
SET_LCD_WR; //WR=1;
Delay_1ms(2);
}
CLR_LCD_WR; //WR=0;
Delay_1ms(2);
CLR_LCD_DATA; //DATA=0;
Delay_1ms(2);
SET_LCD_WR; //WR=1;
Delay_1ms(2);
}
/*============================================
函数功能:写地址
入口参数:ADR:起始地址
返回参数:无
备 注:无
============================================*/
void Write_Adr(uchar Adr)
{
uchar i;
Write_ID(0x05);
CLR_LCD_WR;
Delay_1ms(2);
CLR_LCD_DATA; //DATA=0;
Delay_1ms(2);
SET_LCD_WR;
Delay_1ms(2);
for(i=0;i<5;i++)
{
CLR_LCD_WR;
Delay_1ms(2);
CTLPORTC|=(Adr>>(4-i)) & 0x01;
Delay_1ms(2);
SET_LCD_WR;
Delay_1ms(2);
}
}
/*============================================
函数功能:写数据
入口参数:Dat:数据
返回参数:无
备 注:无
============================================*/
void Write_Data(uchar Dat)
{
uchar i;
for(i=0;i<4;i++)
{
CLR_LCD_WR;
Delay_1ms(5);
CTLPORTC|= (Dat>>i)&0x01;
Delay_1ms(5);
SET_LCD_WR;
Delay_1ms(5);
}
}
/*============================================
函数功能:初始化LCD
入口参数:Dat:数据,CMD:操作码,ADR:RAM地址
返回参数:无
备 注:定义模块:(100 0010 1001) 0X0429;
内部RC 振荡方式:(100 0001 1000) 0X0418;
开振荡器:(100 0000 0001) 0X0401;
开显示器:(100 0000 0011) 0X0403;
==============================================*/
void Init_LCD(void)
{
SET_LCD_CS1;
Delay_1ms(1);
SET_LCD_CS2;
Delay_1ms(1);
SET_LCD_DATA;
Delay_1ms(1);
//====================初始化U1================
CLR_LCD_CS1;
Write_ID(0x04); //定义模块
Write_CMD(0x29);
SET_LCD_CS1;
CLR_LCD_CS1;
Write_ID(0x04); //定义内部振荡方式
Write_CMD(0x18);
SET_LCD_CS1;
CLR_LCD_CS1;
Write_ID(0x04);
Write_CMD(0x01); //开振荡器
SET_LCD_CS1;
Delay_1ms(1);
CLR_LCD_CS1;
Write_ID(0x04);
Write_CMD(0x03); //开显示
SET_LCD_CS1;
Delay_1ms(1);
//====================初始化U2================
Delay_1ms(1);
CLR_LCD_CS2;
Write_ID(0x04); //定义模块
Write_CMD(0x29);
SET_LCD_CS2;
CLR_LCD_CS2;
Write_ID(0x04);
Write_CMD(0x01); //开振荡器
SET_LCD_CS2;
Delay_1ms(1);
CLR_LCD_CS1;
Write_ID(0x04); //定义内部振荡方式
Write_CMD(0x18);
SET_LCD_CS2;
CLR_LCD_CS2;
Write_ID(0x04);
Write_CMD(0x03); //开显示
SET_LCD_CS2;
Delay_1ms(1);
}
这是个液晶程序,其中每个函数基本都要用到这样的语句,期待各位高手指点! |