Hi everyone!
Im new to uC's and more to I2C and after reading datasheets and forum messages I stil cant get it runnig. Im using CW5 and I want to use the I2C module . In main I´ve initialized the MMI2C as follows (this came from a reply to another topic)
MMCR1 = 0x80;
MMCR2 = 0x30; /* Enable I2C master mode, interrupts enabled */
MMFDR = 0x02; /* Freq = 50kHz with 4MHz Xtal*/
MMSR = 0x00;
and then I call I2C_Tx_start() and I2C_Tx_stop() in a while loop. I dont really agree with the code and also tried other options but they wont work either. I want to transmit data to a 24FC512 eeprom using this code (based on MC68HC908AP64 datasheet, page 242)
void I2C_Tx_start (void){
MMSR_MMTXBE=0; /* start condition code
MMCR2_MMRW=0;
MMCR2_MMAST=1;
MMADR = 0xA0; /* Dev. address 00 */
MMSR_MMTXBE = 1;
MMSR_MMTXIF = 1; /* acknowledge */
MMDTR = 0XAA; /* dummy data to memory */
}
void I2C_Tx_stop(void){
MMSR_MMTXBE = 1; /* acknowledge */
MMSR_MMTXIF = 1;
MMCR2_MMNAKIF=1; /* stop*/
MMCR2_MMAST=0;
MMSR_MMTXBE = 1;
}
SCL is low all the time and SDA always high. I believe the problem is in the initialization. The device address is 00 (using A2,A1,A0 = 0) Could someone please give feedback on this problem? Thanks in advance