|
本帖最后由 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[10] EEPROM_SECTION;
- BOOTLOADER_SECTION
- unsigned char sn[10];
- int main(void)
- {
- unsigned char i;
- for(i=0;i<10;i++)
- {
- sn[i]=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,这个序列号的地址是怎么发现的,数据手册好像没有提到,我怎么没有看到呢 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|