[an error occurred while processing this directive]
|
чтение из 24с256 - без проблем (прошивал через лошадь тестовый код)
записывает блоками если между этими записями делаю паузу jtag-ом
;--------------------------------------------------------------------
; запись (блоками по 64 байта) EEPROM
;
; xl xh - адрес RAM
; yl yh - адрес ячейки EEPROM
; zl zh - длина блока
; tempC - адрес eeprom
; tempA,tempB,tempD,data - врем.
;--------------------------------------------------------------------
page_write_eeprom:
rcall twi_start
brne ERROR_W
rcall twi_sla_w
brne err_st
rcall twi_adr
brne err_st
ldi tempD,64
pwe: rcall twi_stop adiw yl,32 sbiw zl,32 mov tempA,zl wait_int_twi: twi_start: ;--------------------------------------------------------------------- twi_stop: ; tempC - адрес eeprom twi_adr:
E-mail:
info@telesys.ru
ld data,x+
sts TWDR,yl;data
ldi tempA, (1<
rcall wait_int_twi
cpi tempA,0x28
brne ERROR_W
dec tempD
brne pwe
adiw yl,32
sbiw zl,32
or tempA,zh
brne page_write_eeprom
ret
err_st: ;rcall twi_stop
ERROR_W: ;cpi tempA,0x20
;breq page_write_eeprom
rjmp ERROR_W
;----------------------------------------------------------------------
lds tempA,TWCR
sbrs tempA,TWINT
rjmp wait_int_twi
lds tempA,TWSR
andi tempA, 0xF8
mov tempB,tempA
ret
;---------------------------------------------------------------------
ldi tempA,(1<
rcall wait_int_twi ;
cpi tempA, 0x08 ;
breq er_tw_s
cpi tempA, 0x10
er_tw_s: ret
; Z=1 - gud Z=0 -ERROR
ldi tempA,(1<
ret
;---------------------------------------------------------------------
twi_sla_w:
mov tempA,tempC
andi tempA,0xFE ; SLA-W
sts TWDR, tempA
ldi tempA, (1<
rcall wait_int_twi
cpi tempA,0x18
ret ; Z=1 - gud Z=0 -ERROR
;---------------------------------------------------------------------
; yl yh - адрес ячейки EEPROM
sts TWDR,yh ; h-ADR
ldi tempA, (1<
rcall wait_int_twi
cpi tempA,0x28
brne er_tw_adr
sts TWDR,yl ; l-ADR
ldi tempA, (1<
rcall wait_int_twi
cpi tempA,0x28
er_tw_adr:
ret ; Z=1 - gud Z=0 eRROR
Ответы