I am using the mP I2C library routines to control the I2C hardware on a PIC18F4550 as the sole master device on the bus. As I am seeing some intermittent anomolous behaviour, I would be grateful for a little clarification of the way the library code operates:
1. The I2C_Start and I2C_Wr functions return an error flag. Presumably "bus busy" at time of entry to these routines is one error that is flagged, but are any other error conditions detected?
2. Do the library routines contain timeout logic to permit recovery from a bus that is stalled because of a (confused) slave device that is permanently asserting the clock-stretch condition or do they just loop indefinitely (and thereby crash the master device also)?
I2C Library questions
Thanks Florin. I am not saying that the library routines do not work in certain controlled circumstances. In fact most of the time they work for me too!yo2lio wrote: I'm using I2C library with success, on EasyPIC4 board and PIC18F452.
However their documentation is inadequate for my purpose.
This is not the first time I have used the I2C bus (but thank you for the thought)yo2lio wrote: Be sure that you have PULL UP resistor on I2C bus !
My current project employs a P18F4550 as I2C bus master to control two dsPIC30F6012A slave devices and I am getting (very) occasional system hangs. The cause of these is probably one of the slaves but I am concerned that when this happens it is the master device that appears to crash and, at the moment, the most likely reason for this seems to be that the program is getting stuck within the mP I2C library routines. Hence my original questions.
Best regards,
Bob
Yea, the library is very basic - mostly works but it's not hard to 'hang' it. The PIC18 I2C state machine is also not perfect and in some processors it's very hard to make certain it won't block itself in specific circumstances.revans wrote: I am not saying that the library routines do not work in certain controlled circumstances.
This thread was really about the [undocumented] error-handling behaviour of the I2C master routines in the mP library.picturkey wrote:hi
i am also working with 18f4550, i am trying to use i2c rutine for along time.
Please note that nobody is saying that the library routines do not work. In fact with simple, well-behaved slaves [e.g. serial EEPROM devices] they are absolutely fine.
That is impossible to say. But you need to study the library documentation and the code examples in conjunction with the data sheet of the slave device that you are trying to use. Beyond that, much can be learnt from writing some simple test programs and monitoring the resulting SDA and SCL waveforms with an oscilloscope.i read all datasheet of 18f4550 but what i did, i can't start to i2c modul. what didn't i make?
For a general understanding of I2C bus, http://en.wikipedia.org/wiki/I2c is quite helpful and contains a link to the "original" Philips specification document.please help me...
Hope this helps,
Bob
Well, if you have any ideas how to do this, we'll take it into consideration. Do some research and give us your feedback.maybe anyone knows how to implement 'autodetect' feature to check if an I2C eeprom is connected or not (sth like plug and play i2c eeprom).
Best regards,
Aleksandar
Web Department Manager
Hi Forum
Aleksander, I have already posted the solution in this topic:
http://www.mikroe.com/forum/viewtopic.p ... 894bc1014c
Aleksander, I have already posted the solution in this topic:
http://www.mikroe.com/forum/viewtopic.p ... 894bc1014c