This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I2C on 89C669

Hi

I Have problem to run the I2C on 89c669.

// function init_i2c
// initializes the I2C peripheral
void init_i2c(void)
{
P1 |= 0xC0; // set P1.6 and P1.7 open drain
TMOD |= 0x01; // timer 0 mode 1
EI2C = 1; // enable I2C interrupts
EA = 1; // global interrupt enable
}

// function rtc_write_byte
// stores a byte in a specific register in the Real Time Clock
// passed is the register address and the byte to store
// nothing is returned
// result of the operation is stored in i2c_status and may be
// I2C_OK or I2C_ERROR
void rtc_write_byte(unsigned char address, unsigned char byte)
{
i2c_storage_address = address; // copy the register address
i2c_byte = chartobcd(byte); // convert to BCD and copy the byte
i2c_status = I2C_BUSY; // I2C is now busy
i2c_operation = WRITE; // a write operation is being performed
I2CON = 0x40; // enable the I2C perhiperal
// no acknowledgements will be returned
I2CON |= 0x20; // request a start condition is transmitted
// therefore putting I2C perhiperal in Master Transmitter mode
while(i2c_status == I2C_BUSY); // wait until I2C is not busy
}

and after that i wait for an Interrupt.
But nothing happens.

I've changed my sfr to
sfr I2ADR = 0x94;
sfr I2CON = 0x91;
sfr I2DAT = 0x93;
sfr I2CLH = 0x96;
sfr I2CLL = 0x95;
sfr I2STA = 0x92;

Need help please.

/Ingo

0