 |
| Author |
Message |
|
|
Posted: Apr 16, 2006 - 07:58 AM |
|

Joined: Aug 29, 2004
Posts: 26
|
|
I'm trying to get TWI working to communicate with a Real Time Clock, just for fun. Unfortunately I'm not having much luck. (Even using peter fleury's I2CMaster.h)
I'm pulling SCL and SDA high with 4.7k resistors.
I attatched an oscilloscope to SCL to see what was happening.. but nothing seems to be happening! Since it should be sending the start condition over and over again in a loop, I would have assumed there would be some activity.
[edit] As far as I can tell the AVR (mega16L) never gets past this while loop:
Code:
// send START condition
TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
// wait until transmission completed
while(!(TWCR & (1<<TWINT)));
Shouldn't the AVR be able to send the start condition even if there was a dead / no chip at all connected to the SCL and SDA pins? What would stop it sending the condition / realising its sent it?
Thankyou for any help in advance,
Plex |
|
|
| |
|
|
|
|
|
Posted: Apr 18, 2006 - 12:13 AM |
|


Joined: May 26, 2004
Posts: 1869
Location: Las Vegas, Nevada
|
|
| It should be able to send the start condition even with nothing connected, because until it completes a transfer it can't know if there's a device connected. I'm not sure, though, whether it can send one start condition after another without a data byte in between. I've made it lock up by sending two stop conditions one after another. Run a proper start/address cycle and see if that makes any difference. You probably should check the TWWC bit in TWCR, and look at the status register, for further clues. |
|
|
| |
|
|
|
|
|
Posted: Apr 18, 2006 - 01:32 AM |
|

Joined: Apr 12, 2005
Posts: 899
|
|
Hmmm, I used Fleury's I2C stuff without ANY problems at all. So, since you have an o-scope, why don't you try simple toggling the TWI pins in software, just high-low-high.... to see that the pins are working and the scope is showing you what you expect to see.
Then use the non-interrupt driven functions to see how the I2C pins are working, then use the interrupt driven functions. For me, they all work fine.
-Tony |
|
|
| |
|
|
|
|
|
Posted: Apr 18, 2006 - 03:07 AM |
|

Joined: May 11, 2005
Posts: 4
|
|
| I am getting this exact same problem as well |
|
|
| |
|
|
|
|
|
|
|