0
我试图在AtmelStudio 7中使用汇编语言将数字0-9写入EEPROM存储器。我做了一个循环,直到计数器达到8(它存储在R17中,计数器存储在R16中)。 ATmega16中的EEPROM为512字节,所以我需要两个寄存器(低字节和高字节)来指向该内存。 一切工作正常,除了我不能找到一种方式来跟踪EEPROM内存来检查数据是否正在写入。希望有人给我AtmelStudio 7 下面的提示是我的代码:在装配中的ATmega16 EEPROM存储器上写入一些数字
; Replace with your application code
start:
/* Define a counter in R16 */
ldi R16,0
ldi R17,8
/* EEPROM Address to be written */
ldi R18,0x00
ldi R19,0x00
/* Loop through this untill 9 numbers are written */
EEPROM_WRITE:
/* Wait untill the EEWE gets 0 */
/* Skip next instruction if EEWE is clear in EECR */
sbic EECR,EEWE
rjmp EEPROM_WRITE
/* Write the address to be filled with the number :D */
out EEARL,R18
out EEARH,R19
/* Write the data */
/* Counter can be used itself */
out EEDR,R16
/* Write logical one to the EEMWE */
/* Set bit immediate */
sbi EECR,EEMWE
/* Start write */
sbi EECR,EEWE
/* Add 1 to the counter */
inc R16
/* Go to the next address on EEPROM */
inc R18
/* Check the loop end point */
cp R16,R17
brne EEPROM_WRITE
rjmp EEPROM_WRITE
rjmp start
从EEPROM中读取就像写入,除非您设置EERE然后读取EEDR。或者,您可以使用并行,SPI或JTAG接口从芯片外部读取EEPROM。 –