在装配时在ATmega16 EEPROM存储器上写一些数字

时间:2017-03-17 07:27:04

标签: assembly avr atmega16

我正在尝试使用AtmelStudio 7中的汇编语言将数字0-9写入EEPROM存储器。我循环直到计数器达到8(存储在R17中,并存储在R16中的计数器)。 ATmega16中的EEPROM是512字节,所以我需要两个寄存器(低字节和高字节)来指向该存储器。 一切都工作正常,除了我找不到跟踪EEPROM内存以检查数据是否被写入的方法。希望有人给我一个AtmelStudio 7的提示。 这是我的代码:

; 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

1 个答案:

答案 0 :(得分:0)

如果要在atmel工作室中跟踪EEPROM,则需要启动调试会话和打开内存窗口(Alt + 6)。应该有下拉列表,应该是eepom选项。您可以在那里验证您的数据。