I2C comment
Kiwi
Posts: 85
I have written a simple I2C communcation routine.
Can somebody gave any comment concerning the subroutines
to use the current read model, beware that it writes to $00 and read from $01, like the specs of the 24LC01 said
Kurt
Can somebody gave any comment concerning the subroutines
to use the current read model, beware that it writes to $00 and read from $01, like the specs of the 24LC01 said
Kurt
Comments
With I2C you should never pull the SDA or SCL lines high with the SX.
That is the job of the pull-up resistor.
The SX code should only pull the lines low or allow them to float (input).
Look at the code generated by the SX/B I2C commands.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
"Ability may get you to the top, but it takes character to keep you there."
·
Its handy that the SX's pin direction definition is identical to what the data on the bus is, a 1 in the pin direction is a 1 on the bus, and a 0 in the pin direction is a 0 on the bus.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 2/7/2006 4:40:27 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
"
To distill what Bean is saying, when operating an open collector bus (which I2C is), instead of changing the data in the register, you instead change the pin direction from input to output and vice versa. When you set up the pin, you write a 0 to the bit(s) and you never change it(them) again. When you want the output to be 1, set the pin's direction to input. When you want the output to be 0, you set the pin's direction to output. The key is allowing the external pullup resistor to supply the 1 value.
Its handy that the SX's pin direction definition is identical to what the data on the bus is, a 1 in the pin direction is a 1 on the bus, and a 0 in the pin direction is a 0 on the bus."
Kurt
This explains the reason for using open collector busses, do you need more detail on how its implemented in an SX program as well?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 2/8/2006 3:39:03 PM GMT
kurt
to create logic 0,
mov rc,#$00 put zero in rc register
mode $0F
mov !rc,#$00 make rc as output, with the value of 1° line
to create a logic 1,
mode $0F
mov !rc,#$FF
so i have to replaced all my setb and clrb with the above line according of what i need
correct??
can i use movB for switching bewteen Inputs and outputs?
ps:the examples are always welcome