I2C Transmission problem

Discussion created by Guest on Mar 22, 2009
Latest reply on Mar 22, 2009 by Guest



First, I would like to point out that I tried to read most of the messages related to I2C posted on this Forum and the AN2318, but I could not find solution to my problem.



No pulse is transmitted from the master to the slave when the master is supposed to transmit 8bytes of data. (I am using an oscilloscope to check SCL and SDA lines)

While I debug the code (from AN2318SW) I can observe that the execution hangs at 


while(TxBufferemptyflag == CLEAR){} /*wait while message is transmitted */

from the master side. 



Description of my set up:

1. Currently two Dragon-12 Plus Boards (with MC9S12DG256B) are used as master and slave.

2. SCL and SDA lines with 2.2kohm resistors to Vcc(5V). 

3. Concerning the code, AN2318SW master and slave codes are used.

4. Modifications that I made to the code/project: 

   - From the function ConfigureI2CModule(void) for both master and slave, 

     Iic.ibfd.byte = 0x00; -->  Iic.ibfd.byte = 0x1F;

     // Because Bus_clock=24Mhz, desired I2C_bus = 100kbps => SCLDivider = 240 => IBFD = 0x1F

   - added a source file called isr_vector.c to the projects of the master and the slave

     to specify that _I2CISR is the I2C ISR.



The main.c of the master has preprocessor 

#define  SLAVE 0xF0

and its ConfigureI2CModule() function has

Iic.ibad.byte = 0x0A;


while the main.c of the slave has preprocessor

#define SLAVE 0xA0

and its ConfigureI2CModule() function has 

Iic.ibad.byte = 0xF0;


In the latter case(slave), shouldn't  #define SLAVE 0xA0 be #define SLAVE 0x0A?

Or in the former case(master), shouldn't Iic.ibad.byte = 0x0A; be Iic.ibad.byte = 0xA0;?

Actually I tried both ways, but this didn't solve my problem. 



The reference source code is at AN2318SW.


I look forward to get your help.