|
|
View previous topic :: View next topic |
Author |
Message |
lboghy
Joined: 04 Jun 2008 Posts: 23
|
i2c speed |
Posted: Wed Sep 21, 2011 4:18 am |
|
|
Hello.
I want to use i2c routine with a speed lower than 100KHz. Can this be done with #use i2c?
Ihave now:
#use i2c(Master,SLOW,sda=PIN_C4,scl=PIN_C3,restart_wdt,force_hw) |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Wed Sep 21, 2011 4:40 am |
|
|
Probably....You can set a 'wanted' clock rate, with:
SLOW=50000 for example
However you need to read the data sheet for your chip. Using the hardware I2C, how fast and slow you can go will depend on the clock rate. The compiler will try to get as close as possible to what you ask for, but if the timing is not possible from your master clock, you can still end up with a very wrong value...
The exact details of the baud rate generator, depend on the chip involved, but (for example), if you were running off a 48MHz master clock with a 18F4550, the I2C clock is given by FOSC/(4*(SSPADD+1)). For the BRG, the SSPADD register is 7bit only, so the lowest clock rate that could be generated for this master clock, would be:
48000000/(4*(127+1)) = 93750Hz.
So for this particular chip running this fast, rates below 93750Hz, can't be done.
However if your master clock is slower, the corresponding rates drop....
Best Wishes
Best |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|