Source Code:

    

      
;.INCLUDE "M32DEF.INC" LDI R21,HIGH(RAMEND) OUT SPH,R21 LDI R21,LOW(RAMEND) OUT SPL,R21 CALL I2C_INIT CALL I2C_START LDI R27, 0b11010000 CALL I2C_WRITE LDI R27, 0b11110000 CALL I2C_WRITE CALL I2C_STOP HERE: RJMP HERE ;********************************************************* I2C_INIT: LDI R21, 0 OUT TWSR,R21 LDI R21, 0x47 OUT TWBR,R21 LDI R21, (1<<TWEN) OUT TWCR,R21 RET ;********************************************************* I2C_START: LDI R21, (1<<TWINT)|(1<<TWSTA)|(1<<TWEN) OUT TWCR,R21 WAIT1: IN R21, TWCR SBRS R21, TWINT RJMP WAIT1 RET ;********************************************************* I2C_WRITE: OUT TWDR, R27 LDI R21, (1<<TWINT)|(1<<TWEN) OUT TWCR, R21 WAIT3: IN R21, TWCR SBRS R21, TWINT RJMP WAIT3 RET ;********************************************************* I2C_STOP: LDI R21, (1<<TWINT)|(1<<TWSTO)|(1<<TWEN) OUT TWCR, R21 RET