hantto
Member
Hello! I have written my own I²C routines. They all work except the send byte routine. I have looked it over and over and over again, but I can't see the flaw. If I replace it with a cruder routine (which takes more space) it works fine.
Here's the code:
Can you see something wrong with it? If you need aditional info about the called routines in the code, please let me know.
Sincerely Hantto
Here's the code:
Code:
I2C_Send_Byte movwf I2C_Temp ;Move W to Temp
movlw d'8' ;Move 8 to W
movwf I2C_Count ;Move W to Counter
call I2C_SDA_Output ;Set SDA as Output
I2C_Send_Bit bcf I2C_SDA ;SDA Low
rlf I2C_Temp, f ;Rotate Temp trough carry
btfsc status, c ;Test carry
bsf I2C_SDA ;If set, set SDA High
call I2C_Pulse_SCL ;Pulse SCL (~10µS total time)
decfsz I2C_Count, f ;Decrease counter
goto I2C_Send_Bit ;Do next bit
return ;Quit if done (if counter = 0)
Can you see something wrong with it? If you need aditional info about the called routines in the code, please let me know.
Sincerely Hantto