我是个AVR初学者 请高手帮我看看我的这个程序哪错了 下载不了程序,flash不能校验 谢谢!!!!
#include<iom16v.h>#include<macros.h>#include"Delaytime.c"#defineucharunsignedchar#def...
#include<iom16v.h>
#include<macros.h>
#include"Delaytime.c"
#define uchar unsigned char
#define uint unsigned int
const uchar table[]="I LIKE AVR !";
void Check_Busy()
{
DDRB=0X00; //PB口置为输入口,准备读取数据
PORTA&=0xFE;
PORTA|=0x02;//读命令操作
PORTA|=0x04;
while(0X80 & PINA); //监测忙信号,直到忙信号为0,才能进行读写操作
PORTA&=0xFB; //EN=0
DDRA = 0XFF; //PB口置为输出口,准备向端口发送数据
}
void write_com(uchar com)
{
Check_Busy();
PORTA&=0xFE; //RS为低
PORTA&=0xFD; //RW为低
PORTB=com;
PORTA|=0x04; //设置E为高
delay_ms();
PORTA&=0xFB;//设置E为低
}
void write_dat(uchar dat)
{
Check_Busy();
PORTA|=0x01; //RS为高
PORTA&=0xFD; //RW为低
PORTB=dat;
PORTA|=0x04; //设置E为高
delay_ms();
PORTA&=0xFB;//设置E为低
}
void main()
{
uchar i;
DDRB=0xFF;
PORTB=0X00;
DDRA|=0x07;
PORTA&=0xFB;//初始E为低
write_com(0x01);
delay_nms(15);
write_com(0x38);
delay_nms(15);
write_com(0x0F);
delay_nms(15);
write_com(0x06);
delay_nms(15);
write_com(0x0C);
delay_nms(15);
write_com(0x80+0);
delay_nms(15);
for(i=0;i<12;i++)
{
write_dat(table[i]);
delay_nms(15);
}
}
编译能通过,校验flash不勾没显示字符 展开
#include<macros.h>
#include"Delaytime.c"
#define uchar unsigned char
#define uint unsigned int
const uchar table[]="I LIKE AVR !";
void Check_Busy()
{
DDRB=0X00; //PB口置为输入口,准备读取数据
PORTA&=0xFE;
PORTA|=0x02;//读命令操作
PORTA|=0x04;
while(0X80 & PINA); //监测忙信号,直到忙信号为0,才能进行读写操作
PORTA&=0xFB; //EN=0
DDRA = 0XFF; //PB口置为输出口,准备向端口发送数据
}
void write_com(uchar com)
{
Check_Busy();
PORTA&=0xFE; //RS为低
PORTA&=0xFD; //RW为低
PORTB=com;
PORTA|=0x04; //设置E为高
delay_ms();
PORTA&=0xFB;//设置E为低
}
void write_dat(uchar dat)
{
Check_Busy();
PORTA|=0x01; //RS为高
PORTA&=0xFD; //RW为低
PORTB=dat;
PORTA|=0x04; //设置E为高
delay_ms();
PORTA&=0xFB;//设置E为低
}
void main()
{
uchar i;
DDRB=0xFF;
PORTB=0X00;
DDRA|=0x07;
PORTA&=0xFB;//初始E为低
write_com(0x01);
delay_nms(15);
write_com(0x38);
delay_nms(15);
write_com(0x0F);
delay_nms(15);
write_com(0x06);
delay_nms(15);
write_com(0x0C);
delay_nms(15);
write_com(0x80+0);
delay_nms(15);
for(i=0;i<12;i++)
{
write_dat(table[i]);
delay_nms(15);
}
}
编译能通过,校验flash不勾没显示字符 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询