Discussion in "Project Doubts" started by    scorcho    Dec 6, 2006.
Wed Dec 06 2006, 12:24 pm
#1
Hi,
Does anyone have any experience with I2C on a Toshiba TMP91CP/FY27? Or is I2C similar across various MCUs?

I'm trying to interface a master ASIC with my slave MCU. The ASIC actually expects a slave I2C EEPROM, so I'm trying to emulate the EEPROM with my MCU. Basically my I2C code consists of 2 parts:

initialize I2C
- setup ports
- setup MCU as slave receiver, 8bits, ACK generation
- setup slave address of MCU
- enable serial interrupt

I2C interrupt service routine
- check various status bits(master/slave?, receiver/transmitter?, arbitration lost?, slave address match?, general call match?, last received bit?)
- based on those status bits read or write to and from the serial buffer

Do these seem like the right steps? Currently my MCU is able to detect and ACK the device/word address that the ASIC is sending, but once it comes to actually sending the data to the ASIC, I get extremely weird and inexplicable problems, such as:

If I send the first byte anything other than a constant, my 2nd byte will be extended by 1 bit, i.e. the interrupt will occur 1 bit after the ACK. My MCU will then be put into receive mode for some reason. Therefore, buffer = 0x00 works but buffer = data doesn't(where data is a char variable)

Assuming I send the first byte as a constant and I get to the 2nd byte, if I set the buffer to anything at all, the MCU will be put into receive mode again. If I don't set the serial buffer at all, the SDA line will be high, hence the ASIC will receive all 0xFFs.

I also noticed that adding instructions in the ISR(even too many dummy nops) will cause the program behavior to differ.

Does this sound weird or what?!
Fri Dec 15 2006, 12:08 pm
#2

my 2nd byte will be extended by 1 bit


This problem might be coz... you are using the same recieve routine which you wrote for recieving address. or it maybe coz of the clock function it generate interrup at the wrong time.

and regarding high of SDA line, try putting some NOPs so that the voltage settle on output pin.

and make sure your ASIC doesn't have a high speed. usually the emulated I2C work at a maximum of 60-70Kbps. so make sure you are not above that.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Robertrip
Fri Apr 26 2024, 11:20 am
ArnoldDiant
Fri Apr 26 2024, 03:53 am
RodneyKnorb
Thu Apr 25 2024, 07:08 pm
Williamjef
Thu Apr 25 2024, 02:08 pm
SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am
ztaletpzca
Wed Apr 24 2024, 11:19 pm
IrardlPex
Wed Apr 24 2024, 08:42 pm