logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

Przykład zapisu/odczytu zmiennej float do EEPROM AVR 2313 w C (WinAVR)

nasiono 11 Sie 2005 21:09 1800 3
REKLAMA
  • #1 1726630
    nasiono
    Poziom 17  
    Posty: 355
    Pomógł: 1
    Ocena: 4
    Witam.
    Mam pytanie jak zapisywać/odczytywać dane do/z wew. eepromu uP avr 2313 pod C w WinAvr.
    Przeszukiwałem forum ale nic pomocnego nie znalazłem, dokumentacja nie na wiele mi sie zda z powodu kiepskiej znajomości jęz.ang.
    Proszę kogoś obeznanego w temacie o jakiś prosty przykład z zapisywaniem i odczytem zmiennej float do eepromu wewnętrznego.
  • REKLAMA
  • #2 1726684
    Machoni
    Poziom 13  
    Posty: 55
    Pomógł: 1
    Ocena: 1
    Sciagnij sobie pdf do Tiny2313... tam masz przyklady kodu w ASM i C.
  • REKLAMA
  • #3 1726743
    LordBlick
    VIP Zasłużony dla elektroda
    Posty: 5438
    Pomógł: 549
    Ocena: 69
    Ja poradzę tylko w ASM (procedurki przepisują EEPROM «» RAM):
    SeqRead32ItEEPROM:
    	ldi	CountBtL, 0x04 ; Number of bytes to write 32 bits to EEPROM
    ;Proc SeqReadIntrEEPROM(CountBtL<- No. of bytes, XL:XH <- SRAMStartAddr, ZL:ZH <- EEPROMStartAddr )
    SeqReadIntrEEPROM:
    	sbic EECR, EEWE	; if Internal EEPROM Read is Enabled, it's posible to operation
    	rjmp SeqReadIntrEEPROM
    	out EEARL, ZL
    	out EEARH, ZH
    	ld DataAcc, Z+      ; Increment Z point easly 
    	sbi	EECR, EERE	;	set Internal EEPROM read bit
    SeqReadIntrEEPROMLoop:
    	sbic EECR, EERE	;	wait until Internal EEPROM read bit become hardware clear
    	rjmp SeqReadIntrEEPROMLoop
    	in	DataAcc, EEDR
    	st	X+, DataAcc
    	dec CountBtL
    	brne SeqReadIntrEEPROM
    	ret
    -------------------------------------
    SeqWrite32ItEEPROM:
    	ldi	CountBtL, 0x04 ; Number of bytes to write 32 bits to EEPROM
    ;Proc SeqWriteIntrEEPROM(CountBtL<- No. of bytes, XL:XH <- SRAMStartAddr, ZL:ZH <- EEPROMStartAddr )
    SeqWriteIntrEEPROM:
    	sbic EECR, EEWE	; if Internal EEPROM Write is Enabled, it's posible to operation
    	rjmp SeqWriteIntrEEPROM
    	out EEARL, ZL
    	out EEARH, ZH
    	ld DataAcc, Z+      ; Increment Z point easly 
    	ld	DataAcc, X+
    	out	EEDR, DataAcc
    	cli
    	sbi	EECR, EEMWE	;	set Internal EEPROM master write bit
    	sbi	EECR, EEWE	;	set Internal EEPROM write bit
    	sei
    	dec CountBtL
    	brne SeqWriteIntrEEPROM
    	ret
    

    --
    Pozdrawiam, Daniel
  • #4 1977324
    nasiono
    Poziom 17  
    Posty: 355
    Pomógł: 1
    Ocena: 4
    odpowiedź otrzymałem jusz w jnnym temacie więc uważam ten temat za zamknięty.
    Za odpowiedzi wszystkim dziękuje
REKLAMA