IBFD = 0x14; // init IBFDIBAD = 0xA0; // set slave address IBCR |= 0b10000000; // IBEN = 1 - IIC bus enableIBCR |= 0b01000000; // IBIE = 1 - IIC interrupt enable while(IBSR&0b00100000) { printf("wait until bus is free"); }; printf("bus free"); IBCR |= 0b01000000; // IBIE = 1 - IIC interrupt enable IBCR |= 0b00010000; // TX/RX = 1 - transmit mode IBCR |= 0b00100000; // MS/SL = 1 - master mode - START signal printf("START"); IICDR = 0b10010000; // address slave printf("slave addressed");
IICDR = 0b10010000;leaving the SDA high (5 V) and the SCL low (0 V).
// I2C Interrupt Handler: *((unsigned char *)0x3fa3) = 0x06; // JMP opcode *((void (**)(void))0x3fa4) = I2Chandler;#pragma interrupt_handler I2Chandlervoid I2Chandler(void){ i2c_flag = 1;}