帮忙编译个程序,我怀疑自己的ICC有问题,程序很简单,但出不来正确结果,帮忙编译下,hex发到我的邮箱,谢谢了!
我的邮箱:heyzzk@yeah.net
#include<iom128v.h>//atmega128l
#include<macros.h>
#define RS(n) {PORTG=((PORTG&0XFE)^n);}
#define RW(n) {PORTG=((PORTG&0XFD)^(n<<1));}
#define E(n) {PORTG=((PORTG&0XFB)^(n<<2));}
#define PSB(n) {PORTG=((PORTG&0XF7)^(n<<3));}
#define RESET(n) {PORTG=((PORTG&0XEF)^(n<<4));}
#define PORT_LCD PORTC
void delay(unsigned int t);
void Write_Command(unsigned char dat);
void Write_Data(unsigned char dat);
void clear();
void show_num(unsigned char y,unsigned char n);
unsigned int temp;
unsigned int x;
void main()
{
DDRG=0xff;
DDRC=0xff;
RESET(1);
PSB(1);
clear();
while(1)
{
show_num(0X80,25);
show_num(0X90,25);
show_num(0X88,25);
show_num(0X98,25);
}
}
void delay(unsigned int t)
{
unsigned int i;
for(i=0;i<t;i++)NOP();
}
void Write_Command(unsigned char dat)
{
RS(0);
RW(0);
E(1);
PORT_LCD=dat;
NOP();NOP();NOP();NOP();
E(0);
}
void Write_Data(unsigned char dat)
{
RS(1);
RW(0);
E(1);
PORT_LCD=dat;
NOP();NOP();NOP();NOP();
E(0);
}
void clear()
{
unsigned char i,j,k=0x80;
Write_Command(0x3c); //设置8BIT控制,绘图OFF
for(i=0;i<32;i++)
{
Write_Command(k++); //设置绘图区的Y地址坐标
Write_Command(0x80); //设置绘图区的X地址坐标
for(j=0;j<16;j++)
Write_Data(0x00);
}
k=0x80;
for(i=0;i<32;i++)
{
Write_Command(k++); //设置绘图区的Y地址坐标
Write_Command(0x88); //设置绘图区的X地址坐标
for(j=0;j<16;j++)
Write_Data(0x00);
}
Write_Command(0x3e); //设置8BIT控制,绘图ON(显示图形)
}
void show_num(unsigned char y,unsigned char n)
{
Write_Command(0x38);
Write_Command(y);
Write_Data(n/100+'0');
Write_Data(n/10%10+'0');
Write_Data(n%10+'0');
Write_Command(0x3e);
} |