/****************************内部EEPROM头文件***************************/
#ifndef __eeprom_H__
#define __eeprom_H__
void EEPROM_write(unsigned int Address, unsigned char Da
void EEPROM_write_num(unsigned int Address, unsigned char Da
unsigned char EEPROM_read(unsigned int Address);//读取一个字节
#endif
/****************************内部EEPROMC文件***************************/
#include "config.h"
/*EEPROM写子入程序*/
//写一个字节
void EEPROM_write(unsigned int Address, unsigned char Da
{
while(EECR & (1<
EEDR = Da
CLI();
EECR |= (1<
}
//写多个字节
void EEPROM_write_num(unsigned int Address, unsigned char Da
{
uchar jj;
for(jj=0;jj
while(EECR & (1<
EEDR = Da
CLI();
EECR |= (1<
Address++;
}
}
/*从EEPROM中读取数据*/
unsigned char EEPROM_read(unsigned int Address)
{
while(EECR & (1<
EECR |= (1<
}
/****************************主函数头文件***************************/
#ifndef __config_H__
#define __config_H__ 1
#include
#include
#define uchar unsigned char
#define uint unsigned int
#include "delay.h"
#include "eeprom.h"
#include "lcd.h"
#endif
/****************************主函数度C文件***************************/
#include "config.h"
void port_init(void);
void main()
{
uchar i;
uint aa;
uchar kk1,kk2;
static uchar j;
uint kk;
uchar tdat[8]={1,2,3,4,5,6,8,7};
uchar rdat[8];
port_init();
LCD1602_initial();
LCD1602_gotoXY(1,1);
LCD1602_sendbyte(iDat,'a');
DDRE=0XFF;
PORTE=0XFF;
kk=86;
while(1)
{
// for(i=0;i<8;i++)
// {
// dat[i]=EEPROM_read(0x01+i);
// }
if(PINC!=0XFF)
{
delayms(20);
if(PINC!=0XFF)
{
for(i=0;i<8;i++)
{
EEPROM_write_num(1000,tdat,8);
}
/* kk1=kk/10;
kk2=kk%10;
EEPROM_write(4000,kk1);
EEPROM_write(4005,kk2);*/
}
}
if(PINF!=0XFF)
{
delayms(20);
if(PINF!=0xff)
{
for(i=0;i<8;i++)
{
rdat[i]=EEPROM_read(1000+i);
}
for(i=0;i<8;i++)
{
LCD1602_sendbyte(iDat,rdat[i]+0x30);
}
/* dat[0]=EEPROM_read(4000);
dat[1]=EEPROM_read(4005);
//dat[1]=dat[4]/10;
//dat[2]=dat[4]%10;
LCD1602_sendbyte(iDat,dat[0]+0x30);
LCD1602_sendbyte(iDat,dat[1]+0x30);
LCD1602_sendbyte(iDat,dat[2]+0x30);
delayms(1000);
j++;*/
}
}
}
}
上一篇:用AVR(ATMEGA128的PWM相频可调)对360度舵机控制
下一篇:AVR(ATMEGA128\16)AD功能(扫描,中断,差分扫描,差分中断)
推荐阅读最新更新时间:2024-03-16 15:16