another question about I2C

Started by elalex_76 May 14, 2006
What frequency do i have to set the bus on the MC9S12DP256B i2c bus? I
am using SRF08 ranging sensors, but i'm not sure if i need to set it
at 100Khz or if the sensors work at a different frequency, and does
anyone know what the SDA hold time is on these devices. I'm really
having a hard time trying to get it to work.
I have posted the code in Message 13950.
My code runs and it finish it, but it is not changing the address in
the device. Please advise me.
Here is the code after some changes:

movb #$1f,IBFD ;
; movb #$e0,IBAD ;HC12 slave address
movb #$80,IBCR ;Set enable bit
bset IBCR,#$30 ;Set Transmit master mode

brclr IBCR, #$20, FAIL

;Transmission
;Generating Start Condition

brset IBSR,#$20,* ;Wait for bus busy flag to clear IBB Flag
movb #$00,IBDR ;Transmit Dev Select and write packet
brclr IBSR,#$20,0+* ;Wait for IBB flag to set

ldx #msg0 ;<<>>
jsr OUTSTRG
brclr IBCR,#$20, FAIL

brclr IBSR,#$02,0* ;Wait for data to be transmitted
bclr IBSR,#~2 ;Clear flag
brset IBSR,#$1,IICSTOP ; Stop if NAK

movb #$00,IBDR ;Transmit 0x00(Data address 0x00)
brclr IBSR,#$2,0+* ;Wait for data to be transmitted
bclr IBSR,#~2 ;Clear flag
brset IBSR,#$1,IICSTOP ; Stop if NAK

ldx #msg1 ;<<>>
jsr OUTSTRG
brclr IBCR,#$20, FAIL

movb #$A0,IBDR ;Transmit 0xa0(Data to write to address 0x00)
brclr IBSR,#$2,0+* ;Wait for data to be transmitted
bclr IBSR,#~2 ;Clear flag
brset IBSR,#$1,IICSTOP ; Stop if NAK

ldx #msg2 ;<<>>
jsr OUTSTRG
brclr IBCR,#$20, FAIL

movb #$AA,IBDR ;Transmit 0xaa (Data to write to address 0x00)
brclr IBSR,#$2,0+* ;Wait for data to be transmitted
bclr IBSR,#~2 ;Clear flag
brset IBSR,#$1,IICSTOP ; Stop if NAK

ldx #msg3 ;;<<>>
jsr OUTSTRG
brclr IBCR,#$20, FAIL

movb #$A5,IBDR ;Transmit 0xa5 (Data to write to address 0x00)
brclr IBSR,#$2,0+* ;Wait for data to be transmitted
bclr IBSR,#~2 ;Clear flag

ldx #msg4 ;;<<>>
jsr OUTSTRG
brclr IBCR,#$20, FAIL

movb #$FE,IBDR ;Transmit 0xe4 (Data to write to address 0x00)
brclr IBSR,#$2,0+* ;Wait for data to be transmitted
bclr IBSR,#~2 ;Clear flag

jsr IICSTOP
bclr IBCR,#$20
;Disable I2C module
bclr IBCR,#$80
swi
FAIL:
ldx #failed ;<<>>
jsr OUTSTRG
rts
;Generate a Stop condition
IICSTOP:
bclr IBCR,#$20
ldx #stoped ;<<>>
jsr OUTSTRG

Alex C.