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
I2C baute rate
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: I2C baute rate
Hello,
Are you using the I2C in hardware or software mode?
Are you using the I2C in hardware or software mode?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
stephan
- Flowcode v5 User
- Posts: 12
- Joined: Wed Nov 17, 2010 8:04 am
- Has thanked: 1 time
- Been thanked: 2 times
Re: I2C baute rate
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
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
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: I2C baute rate
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.
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.
- Attachments
-
- PIC_I2C_Master.c
- (13.57 KiB) Downloaded 301 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
stephan
- Flowcode v5 User
- Posts: 12
- Joined: Wed Nov 17, 2010 8:04 am
- Has thanked: 1 time
- Been thanked: 2 times
Re: I2C baute rate
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
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
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: I2C baute rate
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel