Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/03/04 16:23
Read: times


 
#67875 - I2C-bus and 24LC256 EEPROM
hello,

i've written some code for my P89C664 µC that writes a databyte to the 24LC256 eeprom. This µC has internal i2c-hardware residing on chip. I encountered some problems, most of the time it doesn't work. I've read my eeprom with the "Easy Eeprom reader" from PonyProg.

So, can anybody help me to correct my assembly code?

MasterTransmitByte: mov S1CON,#01100000b ; give start condition
Label1: jnb SI,Label1
mov S1CON,#01000000b ; clear start bit
mov A,S1STA ; read status register
cjne A,#008h,MasterTransmitByte ; restart?

mov S1DAT,#0A0h ;send control byte
Label2: jnb SI,Label2
mov S1CON,#01000000b
mov A,S1STA
mov P2,A
cjne A,#018h,MasterTransmitByte

mov S1DAT,AdresHB ;send address high byte
Label3: jnb SI,Label3
mov S1CON,#01000000b
mov A,S1STA
mov P2,A
cjne A,#028h,MasterTransmitByte

mov S1DAT,AdresLB ;send address low byte
Label4: jnb SI,Label4
mov S1CON,#01000000b
mov A,S1STA
mov P2,A
cjne A,#028h,MasterTransmitByte

mov S1DAT,Databyte ;send databyte
Label5: jnb SI,Label5
mov SI,#01000000b
mov A,S1STA
mov P2,A
cjne A,#030h,MasterTransmitByte

mov S1CON,#01010000b ;five stop condition
acall WaitForWrite ; waiting for internal write cycle to be ended (just a delay loop)
ret


Thanks and greetzzzzz

List of 8 messages in thread
TopicAuthorDate
I2C-bus and 24LC256 EEPROM            01/01/70 00:00      
   RE: I2C-bus and 24LC256 EEPROM            01/01/70 00:00      
   RE: I2C-bus and 24LC256 EEPROM            01/01/70 00:00      
      RE: I2C-bus and 24LC256 EEPROM            01/01/70 00:00      
      RE: I2C-bus and 24LC256 EEPROM            01/01/70 00:00      
   RE: I2C-bus and 24LC256 EEPROM            01/01/70 00:00      
   RE: I2C-bus and 24LC256 EEPROM            01/01/70 00:00      
   RE: I2C-bus and 24LC256 EEPROM            01/01/70 00:00      

Back to Subject List