STC内部EEPROM怎么存入多组数据
1个回答
展开全部
void read(uchar sq,unsigned char * eadd,unsigned char * nbadd,unsigned char size){
unsigned char i = size;
EA = 0;
while(i--){
IAP_ADDRH = sq; //0x10=使用第9扇区
IAP_ADDRL = (char)eadd;
IAP_CONTR = 0x80|IAP_WAIT_TIME; //11M
IAP_CMD = IAP_BYTE_READ; //读命令
IAP_TRIG = 0x5A;IAP_TRIG = 0xA5; //启动IAP
*nbadd = IAP_DATA;
nbadd++;eadd++;
}
IAP_CONTR = 0;
IAP_CMD = 0;
IAP_TRIG = 0;
IAP_ADDRH = 0xff; //重新指向第0扇区
EA = 1;
}
void save(uchar sq,unsigned char *eadd,unsigned char *nbadd,unsigned char size){
unsigned char i = size;
EA = 0;
weism |= dig[0]; //消隐
IAP_CONTR = 0x80|IAP_WAIT_TIME; //11M
IAP_ADDRH = sq; //0x10=第9扇区
IAP_ADDRL = 0x00;
IAP_CMD = IAP_SECTOR_ERASE; //擦除命令
IAP_TRIG = 0x5A;IAP_TRIG = 0xA5; //启动IAP
while(i--){
IAP_ADDRH = sq;
IAP_ADDRL = (char)eadd;
// IAP_CONTR = 0x80|IAP_WAIT_TIME; //11M
IAP_CMD = IAP_BYTE_PROG; //写入命令
IAP_DATA = *nbadd;
IAP_TRIG = 0x5A;IAP_TRIG = 0xA5; //启动IAP
nbadd++;eadd++;
}
IAP_CONTR = 0; //关闭IAP
IAP_CMD = 0;
IAP_TRIG = 0;
IAP_ADDRH = 0xff; //重新指向第0扇区
EA = 1;
}
unsigned char i = size;
EA = 0;
while(i--){
IAP_ADDRH = sq; //0x10=使用第9扇区
IAP_ADDRL = (char)eadd;
IAP_CONTR = 0x80|IAP_WAIT_TIME; //11M
IAP_CMD = IAP_BYTE_READ; //读命令
IAP_TRIG = 0x5A;IAP_TRIG = 0xA5; //启动IAP
*nbadd = IAP_DATA;
nbadd++;eadd++;
}
IAP_CONTR = 0;
IAP_CMD = 0;
IAP_TRIG = 0;
IAP_ADDRH = 0xff; //重新指向第0扇区
EA = 1;
}
void save(uchar sq,unsigned char *eadd,unsigned char *nbadd,unsigned char size){
unsigned char i = size;
EA = 0;
weism |= dig[0]; //消隐
IAP_CONTR = 0x80|IAP_WAIT_TIME; //11M
IAP_ADDRH = sq; //0x10=第9扇区
IAP_ADDRL = 0x00;
IAP_CMD = IAP_SECTOR_ERASE; //擦除命令
IAP_TRIG = 0x5A;IAP_TRIG = 0xA5; //启动IAP
while(i--){
IAP_ADDRH = sq;
IAP_ADDRL = (char)eadd;
// IAP_CONTR = 0x80|IAP_WAIT_TIME; //11M
IAP_CMD = IAP_BYTE_PROG; //写入命令
IAP_DATA = *nbadd;
IAP_TRIG = 0x5A;IAP_TRIG = 0xA5; //启动IAP
nbadd++;eadd++;
}
IAP_CONTR = 0; //关闭IAP
IAP_CMD = 0;
IAP_TRIG = 0;
IAP_ADDRH = 0xff; //重新指向第0扇区
EA = 1;
}
意法半导体(中国)投资有限公司
2023-06-12 广告
2023-06-12 广告
STM32是一种由意法半导体(STMicroelectronics)公司设计和生产的单片机系列,广泛用于嵌入式系统、物联网(IoT)设备、汽车电子、工业自动化等领域。STM32具有以下优点:1. 低功耗:STM32单片机通常具有较低的功耗,...
点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询