[51] Need help with code, suggestion

Status
Not open for further replies.

hithesh123

Full Member level 6
Joined
Nov 21, 2009
Messages
324
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
lax
Visit site
Activity points
3,548
Here's a brief description of what i am trying to do -
I am writing code to replicate open collector communication bus (like I2C).
The device is sending clock and data. The host can take control whenever it likes to.
The host does this by pulling down clock LOW for 100usecs. The device has to respond withing a few millisecs.
I am detecting the 100usecs by using timer interrupt with clock pin input for count direction. (is there a better way?).
with this setup, the timer counts both ways. But I only want it to count down.

when there is no request by host, the device continually keeps transmitting data. so this is in a while loop.
while(! host_request)
But this doesn't work. After completing the host request, there will be nothing to do.
It has to get back to continuous transmission of data.
Any suggestions.

Device is C8051F120
silabs IDE.
 

You didn't tell how you want to "replicate" the bidirectional communication? This requires either special hardware which is able to detect the data direction or full decoding of the I2C protocol.
 

You didn't tell how you want to "replicate" the bidirectional communication? This requires either special hardware which is able to detect the data direction or full decoding of the I2C protocol.

There is no need to detect data direction, the clock is always supplied by the device. Host just loads the data on the data bus.
The device can read on falling edge of clk.
 

I might have misunderstood your intention, but at least SDA is bidirectional in I2C communication.
 

I might have misunderstood your intention, but at least SDA is bidirectional in I2C communication.

There is no need to detect data direction, the clock is always supplied by the device. Host just loads the data on the data bus.
The device can read on falling edge of clk.
This is not I2C. It is like I2C, in the sense that it is open collector.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…