From: hackbard Date: Sat, 10 Jun 2006 11:08:00 +0000 (+0000) Subject: ... X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=faba451aadcb0c9a0a485eaa37df46417e34a857;p=my-code%2Fatmel.git ... --- diff --git a/beginners/i2c-eeprom.asm b/beginners/i2c-eeprom.asm new file mode 100644 index 0000000..d7d2229 --- /dev/null +++ b/beginners/i2c-eeprom.asm @@ -0,0 +1,145 @@ +; +; eeprom via i2c read/write +; +; author: hackbard@hackdaworld.org +; + +; specify device +.include "../include/m32def.inc" + +; ------------------ +; interrupt vectors: +; ------------------ + +; reset +nop +rjmp RESET +; int0 +nop +reti +; int1 +nop +reti +; int2 +nop +reti +; timer 2 compare +nop +reti +; timer 2 overflow +nop +reti +; timer 1 capture +nop +reti +; timer 1 compare a +nop +reti +; timer 1 compare b +nop +reti +; timer 1 overflow +nop +reti +; timer 0 compare +nop +reti +; timer 0 overflow +nop +reti +; spi/stc transfer complete +nop +reti +; usart rx complete +nop +reti +; usart data register empty +nop +reti +; usart tx complete +nop +reti +; adc complete +nop +reti +; eeprom ready +nop +reti +; analog comparator +nop +reti +; twi +nop +reti +; spm ready +nop +reti + +; ----- +; code: +; ----- + +RESET: +; set stackpointer +ldi r16,high(RAMEND) ; write top of ramend (highbyte) +out SPH,r16 ; to stackpointer +ldi r16,low(RAMEND) ; write top of ramend (lowbyte) +out SPL,r16 ; to stackpointer + +; rs232 init +ldi r16,12 ; "76,8k bps @ 16 mhz" in r16 +out UBRR,r16 ; write to uart baudrate register +ldi r16,(1< prescaler = 4 +;andi r16,0xfd +sbi TWSR,TWPS0 +cbi TWSR,TWPS1 +;out TWSR,r16 ; write to twi status register + +ldi r16,(1<