|
|
View previous topic :: View next topic |
Author |
Message |
Dhiren Guest
|
Changing clock rate of I2C |
Posted: Thu Jul 22, 2004 8:03 am |
|
|
I am using the i2c protocol on the PIC18F452 to communicate with the NRI low powered coin unit. The PIC is using a 20 MHz crystal. The coin unit needs the SCL line to be clocked at 11KHz. How do I change the SCL clock to this rate using the CCS compiler PCH 3.169???
If not possible with the CCS compiler, any other idea how I may communicate with the coin unit???
Please help !!! |
|
|
valemike Guest
|
|
Posted: Thu Jul 22, 2004 8:07 am |
|
|
What is the address of the slave device? The speed of the PIC's i2c is determined by slave address i think. Look in the datasheet. A higher number for the address yields a slower data rate.
-Mike |
|
|
Ttelmah Guest
|
Re: Changing clock rate of I2C |
Posted: Thu Jul 22, 2004 8:25 am |
|
|
Dhiren wrote: | I am using the i2c protocol on the PIC18F452 to communicate with the NRI low powered coin unit. The PIC is using a 20 MHz crystal. The coin unit needs the SCL line to be clocked at 11KHz. How do I change the SCL clock to this rate using the CCS compiler PCH 3.169???
If not possible with the CCS compiler, any other idea how I may communicate with the coin unit???
Please help !!! |
If it 'needs to be clocked at 11KHz', then it isn't really I2C!...
I2C, has 'maximum' rates, but allows devices to run at any rate below these. 11K, is not a standard maximum rate for I2C.
The CCS C, supports different maximum rates. the keyword 'fast' enables the higher speed rate (potentially, if the clock and hardware support it, at 400KHz), and 'slow' forces the slow I2C spec to be used. However even the latter, is a 100KHz rate (are you sure the speed of the device is 11KHz - 11K is very slow). SPI, had it's earliest versions clocked at 110Khz, and is the only 'standard' bus that I know of using a '11' rate - CanBus, has a version at 33KHz, which is the slowest standard I can think of.
The slowest rate that can be generated by the I2C hardware, on your master clock, is just under 20KHz. If you are not using delays anywhere else, you might (potentially), be able to use the 'soft' I2C, and 'miss-set' the #use delay statement to bring the speed down to 11K. Realistically, you can only get 11KHz, with the hardware I2C, by bringing the processor clock rate down. In software, you could write a 'DIY' handler for this rate, or possibly do the 'cheat' mentioned above.
Best Wishes |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Thu Jul 22, 2004 8:39 am |
|
|
If your NRI unit is truely I2C compatible it should not need a clock frequency of 11KHZ. That is a rather slow rate. If you are having communication problems I would suspect it is something else. If you really do want to communicate with it at that speed I might suggest that you Bit-Bang the SCL and SDA lines, utilizing delays between the 'high' and 'low' of the signals. The clock rate can be controlled quite easily using this technique.
Ronald |
|
|
dseetharan Guest
|
Changing of clock rate |
Posted: Fri Jul 23, 2004 3:00 am |
|
|
I have emailed to NRI guys and they emphasized that the SCL frequency needs to 11KHz. This is quite puzzling since I have an eeprom and real time clock from different manufacturers and they both work perfectly well on the same i2c bus lines!!! Anyway my last resort is to now control the clock line manually by inserting delays to get 11 KHz pulses.
Thanks for the help guys!! |
|
|
|
|
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
|