I2C (IIC) and HCS12

Started by varneybob August 5, 2002
I'm trying to figure out how to program the baud rate for my I2C bus
on the HCS12. The S12IICV2 document describes two equations that
deal with tap points and what not, but I have no idea what a tap
point means. Any help would be appreciated.

My micro will have a 25MHz square wave input clock, which I think
translates to a 12.5MHz bus clock. With those numbers, how can I
compute the necessary values to program the IBFD register for
100Kbp/s and 400Kbp/s??

Thanks.



Here is a 24Mhz setup, change it for yours (25Mhz).

;--------------------------Initialize IIC-----------------------------
----
;100kbps
;IBC7 IBC6 IBC5 IBC4 IBC3 IBC2 IBC1 IBC0
; 0 1 ;MUL
; 0 1 1 ;SCL_Tap=8
SDA_Tap=2
; 0 1 1 ;scl2tap=6
tap2tap=8

;SCL Divider = MUL x {2 x (scl2tap + [(SCL_Tap - 1) x tap2tap] + 2)}
; 2*{2*(6+[(8-1)*8]+2)}%6
;24MHz / 256 = 93.75kHz
;
;SDA Hold = MUL x {scl2tap + [(SDA_Tap - 1) x tap2tap] + 3}
; 2*{2*(6+[(2-1)*8]+2)}d
;24MHz / 64 = 375kHz ; movb #%01011011,IBFD
movb #%10111111,IBFD
movb #%10000000,IBCR > I'm trying to figure out how to program the baud rate for my I2C
bus
> on the HCS12. The S12IICV2 document describes two equations that
> deal with tap points and what not, but I have no idea what a tap
> point means. Any help would be appreciated.
>
> My micro will have a 25MHz square wave input clock, which I think
> translates to a 12.5MHz bus clock. With those numbers, how can I
> compute the necessary values to program the IBFD register for
> 100Kbp/s and 400Kbp/s??
>
> Thanks.





So the 93.75KHz value you have is the clock for the I2C? And since
the standard rate is 100Kbps, should you try to get that value as
close to 100K as possible? Also, does any of this really matter if
all I'm going to be using the MCU for is as a slave? --- In 68HC12@y..., "zeta_alpha2002" <zeta_alpha2002@y...> wrote:
> Here is a 24Mhz setup, change it for yours (25Mhz).
>
> ;--------------------------Initialize IIC---------------------------
--
> ----
> ;100kbps
> ;IBC7 IBC6 IBC5 IBC4 IBC3 IBC2 IBC1 IBC0
> ; 0 1 ;MUL
> ; 0 1 1 ;SCL_Tap=8
> SDA_Tap=2
> ; 0 1 1 ;scl2tap=6
> tap2tap=8
>
> ;SCL Divider = MUL x {2 x (scl2tap + [(SCL_Tap - 1) x tap2tap] + 2)}
> ; 2*{2*(6+[(8-1)*8]+2)}%6
> ;24MHz / 256 = 93.75kHz
> ;
> ;SDA Hold = MUL x {scl2tap + [(SDA_Tap - 1) x tap2tap] + 3}
> ; 2*{2*(6+[(2-1)*8]+2)}d
> ;24MHz / 64 = 375kHz > ; movb #%01011011,IBFD
> movb #%10111111,IBFD
> movb #%10000000,IBCR > > I'm trying to figure out how to program the baud rate for my I2C
> bus
> > on the HCS12. The S12IICV2 document describes two equations that
> > deal with tap points and what not, but I have no idea what a tap
> > point means. Any help would be appreciated.
> >
> > My micro will have a 25MHz square wave input clock, which I think
> > translates to a 12.5MHz bus clock. With those numbers, how can I
> > compute the necessary values to program the IBFD register for
> > 100Kbp/s and 400Kbp/s??
> >
> > Thanks.






> So the 93.75KHz value you have is the clock for the I2C?
Yes

> the standard rate is 100Kbps, should you try to get that value as
> close to 100K as possible?
No - it does not have to be precisely/close as to 100K. Some older
devices like EEPROM will only work upto 100K. Newer devices from
100K to 1M. It is device dependent on what is the max clock speed on
the target device.

> Also, does any of this really matter if
> all I'm going to be using the MCU for is as a slave?
Who is the master? You have to look how much can HS12 be clocked at
max speed then clock speed to that. Haven't looked at that because
in our apps we are only talking to RTC and EEPROM. >
>
> --- In 68HC12@y..., "zeta_alpha2002" <zeta_alpha2002@y...> wrote:
> > Here is a 24Mhz setup, change it for yours (25Mhz).
> >
> > ;--------------------------Initialize IIC-------------------------
--
> --
> > ----
> > ;100kbps
> > ;IBC7 IBC6 IBC5 IBC4 IBC3 IBC2 IBC1 IBC0
> > ; 0 1 ;MUL
> > ; 0 1 1 ;SCL_Tap=8
> > SDA_Tap=2
> > ; 0 1 1 ;scl2tap=6
> > tap2tap=8
> >
> > ;SCL Divider = MUL x {2 x (scl2tap + [(SCL_Tap - 1) x tap2tap] +
2)}
> > ; 2*{2*(6+[(8-1)*8]+2)}%6
> > ;24MHz / 256 = 93.75kHz
> > ;
> > ;SDA Hold = MUL x {scl2tap + [(SDA_Tap - 1) x tap2tap] + 3}
> > ; 2*{2*(6+[(2-1)*8]+2)}d
> > ;24MHz / 64 = 375kHz
> >
> >
> > ; movb #%01011011,IBFD
> > movb #%10111111,IBFD
> > movb #%10000000,IBCR
> >
> >
> > > I'm trying to figure out how to program the baud rate for my
I2C
> > bus
> > > on the HCS12. The S12IICV2 document describes two equations
that
> > > deal with tap points and what not, but I have no idea what a
tap
> > > point means. Any help would be appreciated.
> > >
> > > My micro will have a 25MHz square wave input clock, which I
think
> > > translates to a 12.5MHz bus clock. With those numbers, how can
I
> > > compute the necessary values to program the IBFD register for
> > > 100Kbp/s and 400Kbp/s??
> > >
> > > Thanks.