Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to generate 100kHz I2c clock for 64Mhz Fosc in pic18f66k22

Status
Not open for further replies.

shreyas_patel21

Full Member level 3
Joined
Jan 4, 2011
Messages
181
Helped
15
Reputation
30
Reaction score
14
Trophy points
1,298
Activity points
2,325
Hi all,
I am using pic 18f66k22 device and i am running it on 64Mhz,
Is it possible to set the I2c CLock of 100khz with this frequency of oscillator?
sspxadd register of BRG is only of 7 bit and to generate 100khz of i2c clock the value of sspxadd should be 9f which is greater than 7bit limit.

thank you!
 

thank you, poorchava!

My another problem is that I am using SPI and I2C on the same mssp line, for SPI I have set 4Mhz clock and for I2c I want to use 100khz or 400khz.

would the SPI clock affect the I2C device?
 

If you operate at 64 MHz and then change to 40 MHz in order to achieve 100 kHz I2C clock, then yes - it will affect SPI.

By changing from 64 to 40 MHz I meant changing oscillator settings. SPI clock is derived from main clock and defined as a fration of it. If you clock SPI at 4 MHz with FCLK of 64MHz that means you have FCLK divided by 16. When you change to 40 MHz, then SPI clock will still be 1/16 of FCLK which translates to 2.5 Mhz of SPI clock. You are saying that you are using SPI and I2C on the same MSSP line. I assume it means that you transmit something by SPI and then switch to I2C or the other way around. If that's the case you can use SPI, then switch frequency to 40MHz, then switch to I2C and then change frequency to 64 MHz again. The question is if changing frequency doesn't affect other functionalities especially, that judging from datasheet i get an impression that this MCU is heavily timing/pwm/communication oriented which means that most of the tasks it will probably perform rely heavily on clock frequency.

If you can't change frequency or this would involve serious overall complication, then maybe bit-banging either SPI or I2C would be an acceptable solution? Probably SPI would be easier because it has lower frequency and you can implement such bit-banging using timer interrupts without completely stalling the MCU.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top