MCF5213EVB - I2C Problem

Showing results for 
Search instead for 
Did you mean: 

MCF5213EVB - I2C Problem

Contributor I

I'm using the MCF5213EVB with a camera that can be controlled via I2C.
The problem is, that this camera only supports a maximum I2C frequency of
10 kHz.
The ColdFire is running at 80 MHz and the maximum available divider for I2C frequency is
"3840", if I correctly understand the Ref.Man. (Chapt. 22.5.2).

What I gain is a minimum of 20.83 kHz prescaled I2C frequency, if I calculate right.

Thats too much!
Is there any thinking fault or do I really have to slow down the whole CF to communicate with
this camera?

The resulting problem (I think) is, that I always gain an "Bus Busy Interrupt" at initilization time.

Code is attached below.

and please excuse my english

Message Edited by Alban on 2007-07-24 05:49 PM
Labels (1)
0 Kudos
1 Reply

Contributor I
The "Bus Busy" issue was because the missing of two pull-up resistors (I2C standard). I only have to change the jumpers on the EVB.

But I am still not able to communicate with the camera.

I slowed down the CF to a systemclock of 20 MHz. The resulting I2C frequency is round about 5 kHz, that should fit.

The camera forced a protocol (read action) of:
<START> i2c-adr <ACKN> R/W-Mode <ACKN> dev-adr <ACKN> reg-adr <ACKN> <STOP>
<START> i2c-adr_R/W <ACKN> data <ACKN> NACKN

And between the Comm-Block and the Data-Block have to be a break of at least 2 msec.

I explain my code in words:
1. init (setting i2c-freq and i2c-slave adr.)
2. set I2CR to  " 0 | IEN | MSTA | MTX " (means: enable + master + transmit + "sends START" )
3. write to I2DR the "i2c-adr"
4. wait for IIF and RXAK
5. do step (3.) and (4.) with "R/W-Mode", "dev-adr", "reg-adr" (instead of "i2c-adr")
6. set I2CR to "0x80" (means: enable + slave + receive + "sends STOP")
7. set I2CR to "0x0" (disable I2C-Module; without that I later gain an "arbitration lost")
8. set wait for a bit ( int i = 1000000; while(i--); ) should be enough for 2msec

I think my fault lies in the following lines.
9. do again step (2.) (IEN | MSTA | MTX)
10. do step (3.) with "i2c-adr_R/W"
11. do step (4.)
12. clear MTX (means: change to receive-mode)
13. read from I2DR (dummy read, but same variable as it is for real data)
14. do step (4.)
15. read from I2DR
16. do steps (6.) and (7.)

But the variables that I use to move the content of I2DR always contain the "i2c-adr_R/W" even if I do steps (13.) and (14.) several times in a row.

Please Help.

0 Kudos