News:

;) This forum is the property of Proton software developers

Main Menu

I2C clock rate.

Started by david, Oct 24, 2024, 01:55 PM

Previous topic - Next topic

david

Hi All,
I'm running an 8MHz clock on a hardware I2C port but regardless of what I declare as the Hbus_Bitrate (100, 400, 1000kHz) it always produces a clock frequency around 50kHz.
I know on a 16MHz clock the bus was running at around 100kHz but I had to drop the micro clock to allow a low PWM frequency.  Is there some other declare I should be using in addition?

Cheers,
David

trastikata

Hello David,

can you post the resultant assembler code (all of it) ?

david

Wow - that was fast. 
Sorry but I'll review in the morning.  It's after 3am here and I suspect it may be running as software I2C and I've missed a chunk of hardware I2C set up.  That may explain why it's ignoring the Hbus rate command.

Cheers,
David

david

Doh!  This is embarrassing. 
I was indeed running in software I2C mode and once I added SSPCON1=%00111000 and used Hbus instead of Bus it ran like the wind.
With the speed now set to 400kHz the clock measured 356kHz.  That's fast enough for me.
Moral of the story - don't do coding after 2am.  (I'm sure it had nothing to do with old age.....)

Cheers,
David