I2C Help

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I2C Help

2,040 Views
jesconsa
Contributor I
Hello, I'm still trying with I2C routines that i have seen here in the forum and i'm still haven't got so much success. I'm NOT working with uTasker, perhaps with uTasker is easier but in a first time i want to get it by programming. I could write 1 or 2 bytes (but not more at the same time) on a i2c eeprom with DrSeuss routine (Thanks!): http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&view=by_date_ascending&message.i...
. The more strange is that i have seen all data in the oscilloscope so it might be fine,...when i read the eeprom with a reader (hardware) i only see 1 or 2 bytes (from 4 or 5 that i'm trying to write)

I have also tried with the tecnova_i2c routine (interrupt driven) that comes with Niche Lite stack but the program hangs sending many bytes towards the serial port.


I have studied the datasheet of the MCF52233 but i see all the routines i have used are OK. What is wrong?

Why i'm not able to write more than 1 or 2 bytes in the first routine?, perhaps some other interrupt is avoiding for that?.

Thanks in advance.

Jesus.
Labels (1)
0 Kudos
4 Replies

500 Views
Marreshe
Contributor I
Hi:

From your email it is not clear which peripheral devices you are trying to R/W.  I use the MCF5475 with the I2C
 to talk to a real time clock and an A/D.  You may want to review a generalized tutorial on the I2c bus. 
In general when you read from the device:
Do a write of address to peripheral
Then to read data:
Enable the Acknowledge,
Put the I2C Master in RX mode
Usually you have to do some type of dummy read of the IBDR
Then receive your data
When the transfer is complte, clear the I2SR flag
Disable Acknowledge...generate stop
Restore I2C master to idle state

If you could post the code you are using I or someone else probably could help more....
0 Kudos

500 Views
jesconsa
Contributor I
Sorry, i'm trying to write/read a 24LC16 i2c eeprom. A very simple device to work.

Thanks.

0 Kudos

500 Views
Marreshe
Contributor I
Since you say you have written many drivers, have you tried using polled mode (not interrupt driven)?
Have you tried writing this as a stand alone application...ie no other drivers on the I2C?
Aslo is the speed you are using too fast for the peripheral

Also a problem that I had was the I2C worked really well until I installed an Ethernet driver. The problem was the Ethernet driver over wrote certain setting on the GPIO port, causing the I2C to cease to function. I went in and altered the GPIO settings and all worked well.
0 Kudos

500 Views
jesconsa
Contributor I
Thanks for Reply. I'm trying with DrSeuss routine:

http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&view=by_date_ascending&message.i...


I understand very well the i2c protocol, i have done drivers for others processors, but with coldfire and so many interrupt handlers and variables it's a bit crazy . So thanks for the advice, :smileywink:. I am working with M52233DEMO board and Niche Lite stack.



Marreshe wrote:
Hi:

From your email it is not clear which peripheral devices you are trying to R/W.  I use the MCF5475 with the I2C
 to talk to a real time clock and an A/D.  You may want to review a generalized tutorial on the I2c bus. 
In general when you read from the device:
Do a write of address to peripheral
Then to read data:
Enable the Acknowledge,
Put the I2C Master in RX mode
Usually you have to do some type of dummy read of the IBDR
Then receive your data
When the transfer is complte, clear the I2SR flag
Disable Acknowledge...generate stop
Restore I2C master to idle state

If you could post the code you are using I or someone else probably could help more....




0 Kudos