EEPROM
2009-03-11 by Guido Helmstetter
Hi
This is my first message.
I am going through the tutorial from microcontroler.net. It is very good until the thing with the eeprom. I am not downloading to the tiny45 yet. just observing in studio4.16.
When setting read of eeprom with sbi eecr, eere. eedr displays instantly all so good but not the entry on the eseg table but just xff. looked far and wide there was one entry, of a fix but in c well that is i am using assembler. Nothing on atmel either but i started getting suspicious about 4.16 reading a post in freaks, where there are problems with the latest version of studio. Nonetheless I figure the problem is more likely me. Here is the code.
Thanks in advance well I know this is not going to tickle anyones brain much. But it is a beginning into AVR.
guido
;**************************
.def temp = r16
.def temp1 = r17
.def count = r18
.def count1 = r19
;
.nolist
.include "C:\Program Files\Atmel\AVR Tools\AvrAssembler\Appnotes\tn45def.inc"
.CSEG
.ORG 0000
rjmp start
;***************;delay
delay:
ldi count, 0x00
wait:
ldi count1, 0x00
wait1:
dec count1
brne wait1
dec count
brne wait
ret
;****************;delay
start:
ldi temp, low(RAMEND) ;Stackpointer initialisieren
out SPL, temp
ldi temp, high(RAMEND)
OUT SPH, temp
ldi ZL, low(cnt)
ldi ZH, high(cnt)
rcall EEPROM_read ;read data eeprom
loop:
rjmp loop
EEPROM_read:
sbic EECR,EEPE ;check for write over
rjmp EEPROM_read
clr temp
out sreg, temp ;clear sreg
out EEARL, temp1 ;temp1 inc in table
sbi EECR, EERE ;set read bit
in temp1, EEDR ;return data from table eseg
out PORTB, temp1
rcall delay
inc temp1
cpi temp1, 2 ;inc pointer and check with constant
brne EEPROM_read
ret
.eseg ;Daten im EEPROM definieren
cnt:
.db 0b10101010
.db 0b01010101
Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox
[Non-text portions of this message have been removed]