Hi Everybody, I'm experimenting with Infineon's XC161CJ-controller on an Infineon SK-XC16x starter kit. Most of my routines work now, except the I2C-routines. Sending of data works OK, but the errors occur when I want to receive data. Has anybody on this forum written I2C-routines for this controller? And if so, are you willing to share them? Thanks in advance. :) Kind Regards, Dennis Ebben
Hello Stefan, Thanks for your informative post. Again I've just been working with SMB and don't know I2C at all but I've read they're quite similiar. At first I was confused by the 28 different sources for the interrupt vector but after sorting things out two things were apparent. The fardware modules have a state machine which manages the idle-address-data transfer-idle changes and that the ACK/NACK at the end of each transfer drove the interrupt requests. The most time critical part of the code was during a master read of a slave. You're right the master generates the clock and the slave hardware module shifts out whatever happens to be in the buffer at the time, so the slave had to have data ready in the buffer when the shifting starts! I rolled my own handler which uses dynamically sized packets, a dedicated isr packet buffer, and input and output circular buffers with interrupt protected read and write functions. NACK response includes a retry scheme with timeout error handler, this tolerates delay due to interrupt activity in the receiver module. It's set up for a multimaster connection and I'm still working on the arbitration scheme. Cheers, Barry