I2C Problem

in Propeller 2
I have an issue with configuring a PropCam directly from the P2v. Currently, I have a P1 hooked up and all it does is the initialization:)
The initialization is pretty simple and I have transliterated the code directly from Phil's code which appear as comments throughout:
I have highlighted a place in the code, (4 lines from bottom) where it hangs. If I insert a simple delay rather than the Boolean, it returns but the initialization fails.
I must be doing something pretty stupid to mess it up, but for the life of me, no clue:)
Ideas?
The initialization is pretty simple and I have transliterated the code directly from Phil's code which appear as comments throughout:
PropCam_Initialize
mov i2c_delay,##400
'set serial snapshot
mov i2c_address,$88
mov i2c_register,#1
mov i2c_setting,%0100_0001
call #_Configure
'set exposure
waitx i2c_delay
mov i2c_register,#3 'register 3 sets lower byte of _EXP
waitx i2c_delay
mov i2c_setting, ##_EXP 'set exposure
call #_Configure
waitx i2c_delay
mov i2c_register,#5 'register 5 sets upper byte of _EXP
mov i2c_setting,##_EXP
shr i2c_setting,#8
call #_Configure
ret
_Configure
setb outa,#_SCL 'outa[Scl]~~
waitx i2c_delay
clrb dira,#_SDA 'dira[Sda]~
waitx i2c_delay
clrb outa,#_SDA 'outa[Sda]~
waitx i2c_delay
setb dira,#_SDA 'dira[Sda]~~
waitx i2c_delay
clrb outa,#_SCL 'outa[Scl]~
mov i2c_data,i2c_address 'i2c address
call #_Write_i2c
mov i2c_data,i2c_register 'which register
call #_Write_i2c
mov i2c_data, i2c_setting 'register setting
call #_Write_i2c
setb dira,#_SDA 'dira[Sda]~~
waitx i2c_delay
setb outa,#_SCL 'outa[Scl]~~
waitx i2c_delay
clrb dira,#_SDA 'dira[Sda]~
waitx i2c_delay
ret
_Write_i2c
{{ This section is Low-level I2C write method from Phil's code:
''
'' `Parameters:
''
'' `data: byte to write to I2C
}}
' repeat 8
' dira[Sda] := i2c_data & $80 == 0
' outa[Scl]~~
' i2c_data <<= 1
' outa[Scl]~
' dira[Sda]~
' outa[Scl]~~
' repeat while ina[Sda]
' outa[Scl]~
mov i2c_reps,#8
mov i2c_bit,#7
DataByte_Out
isob i2c_data,i2c_bit wc
setbc dira, #_SDA
waitx i2c_delay
setb outa, #_SCL
waitx i2c_delay
clrb outa, #_SCL
sub i2c_bit,#1
waitx i2c_delay
djnz i2c_reps,#DataByte_Out
clrb dira,#_SDA 'dira[Sda]~
waitx i2c_delay
setb outa,#_SCL 'outa[Scl]~~
wait5 isob ina,#_SDA wc ' repeat while ina[Sda]
if_c jmp #wait5 '<<<<<--------- hangs here
waitx i2c_delay
clrb outa,#_SCL 'outa[Scl]~
waitx i2c_delay
ret
I have highlighted a place in the code, (4 lines from bottom) where it hangs. If I insert a simple delay rather than the Boolean, it returns but the initialization fails.
I must be doing something pretty stupid to mess it up, but for the life of me, no clue:)
Ideas?
Comments