Page 1 of 1
I2C baute rate
Posted: Wed May 18, 2011 3:19 pm
by stephan
hello ,
I want to use I2C communication on EB006V7 with a PIC 16F877A with a clock at 19660800Hz.
Flowcode I2C windows propose to me 3 baute rates preset values 100KHz,400kHz and 1MHz.
I choose a baute rate of 400KHz, but when i look at the scl signal clock with my oscilloscope the frequency was 114KHz,
when i try 100kHz I measure 41kHz and for 1MHz the measure frequency is 178KHz.
I thought that the baute rate was the frequency of I2C clock signal SCL. Am I wrong or right?
Would somebody help me to understand ?
Thanks for all.
Stephan
Re: I2C baute rate
Posted: Wed May 18, 2011 5:05 pm
by Benj
Hello,
Are you using the I2C in hardware or software mode?
Re: I2C baute rate
Posted: Wed May 18, 2011 7:07 pm
by stephan
hello Ben,
I want to control a device that communicate with I2C bus.So I made my eblock (for EB006V7) to place pull-up resistors (1.8K Ohms) to make the bus working.
I made the programm with Flowcode V4 ,and all is working well .
But as I am a curious man I put my oscilloscope probe on SDC ( the clock of I2C bus) and I saw what i explain on my first post .
As I select a baute rate given by Flowcode (100kHz for example) I was waiting for it on my oscilloscope (100kHz too) !
I hope to be clear for you to answer me.
thanks you
Stephan
Re: I2C baute rate
Posted: Thu May 19, 2011 9:43 am
by Benj
Hello Stephan,
I think I may have found the solution, please copy the attached file into your "Flowcode v4/Components" directory before starting Flowcode and the next time you compile to the chip the baud rate should be fixed.
Let me know how you get on.
Re: I2C baute rate
Posted: Thu May 19, 2011 2:59 pm
by stephan
hello Ben
I copied the file you sent me in the dirctory and the results are better:
For a programmed baude rate of 100kHz ,i read 94.5kHz on my oscilloscope.
For a programmed baude rate of 400kHz ,i read 327kHz on my oscilloscope.
Little detail i had to change pull_up resistors from 1.8kOhms to 3.6kOhms because the rise time of SCL (clock signal) was too slow and pluses didn't reach the level supply (+5V) ,but there is no link with the baute rate selection.
As you can see the difference is not constant .What do you think about this?
Was this problem known?
Thanks you .
Stephan
Re: I2C baute rate
Posted: Mon Jun 06, 2011 2:33 pm
by Benj
Hello Stephan,
The Baud rate problem was known but the difference in frequency is not known. It could be that there is a percentage error on the I2C peripheral but more likely it is due to an error in the oscillator either in the speed defined in Flowcode or in the oscillating hardware which is causing this discrepancy. For example an internal oscillator is very likely to have around this percentage of error in speed. If you are using an internal oscillator then there is normally an osctune register or similar to allow you to tweak the oscillator speed.