AVR 序列号 读取写入到片内EEPROM
本帖最后由 askme 于 2012-9-21 15:45 编辑#include <avr/io.h>
#include <avr/boot.h>
#include <avr/eeprom.h>
#include <stdint.h>
#define EEPROM_SECTION__attribute__ ((section (".eeprom")))
unsigned char eeprom_var EEPROM_SECTION;
BOOTLOADER_SECTION
unsigned char sn;
int main(void)
{
unsigned char i;
for(i=0;i<10;i++)
{
sn=boot_signature_byte_get(0x0E+i);
}
boot_page_erase(0x0040);
eeprom_write_block( sn,eeprom_var,sizeof(sn) );
while(1)
{
}
return 0;
}
以上的代码在AVR studio 4.18 716 编译有错误
../Signature.c:20:39: error: invalid suffix "+i" on integer constant
要加个括号就可以了((0x0E)+i)或直接改成14也行,或者(0x07*2+i)等都可以,这是为什么,编译器不认识不会自动调整么,或者改成(i+0x0E)也可以,16进制常量不能放左边先参加运算
随便大家手头上有芯片的话用这个测试一下芯片有没有序列号的
http://www.amobbs.com/thread-5495588-1-1.html我的提问
还有就是0x0E=14,这个序列号的地址是怎么发现的,数据手册好像没有提到,我怎么没有看到呢 AVR有序列号???? 我试了一下,ATTINY24A,0x0E到0x17是有的,字节不一样,应该只要SIGRD标志位可读的应该都有的 MARK!!!!!! 这个只能在bootloader里面运行么
能在主程序里面运行么 {:smile:}{:smile:}{:smile:}{:smile:}{:smile:}{:smile:}{:smile:}
页:
[1]