Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Strange issue with I2C master

Strange issue with I2C master

2013-05-19 by Dave McLaughlin

Hi all,

 

I have an ATMega328P and trying to use the I2C Master interface but when I
send the start bit I am seeing a series of what appears to be clocks on the
SCL line and nothing on the SDA.

 

I would expect SDA to be high at the same time as SCL goes hi and then SDA
goes low but all I see is a clock output on SCL.

 

 

I am using the library from this website.

 

http://homepage.hispeed.ch/peterfleury/group__pfleury__ic2master.html

 

 

Any ideas what I am missing?

 

Dave.

 



[Non-text portions of this message have been removed]

Re: Strange issue with I2C master

2013-05-19 by englsprogeny1

Hi Dave,

Can you give us a code example?

I see that this library is to be used with GCC.

I always use external pullup resistors on my I2C lines.


Is something else trying to write to the DIO used for SDA?








--- In AVR-Chat@yahoogroups.com, "Dave McLaughlin" <dave_mclaughlin@...> wrote:
Show quoted textHide quoted text
>
> Hi all,
> 
>  
> 
> I have an ATMega328P and trying to use the I2C Master interface but when I
> send the start bit I am seeing a series of what appears to be clocks on the
> SCL line and nothing on the SDA.
> 
>  
> 
> I would expect SDA to be high at the same time as SCL goes hi and then SDA
> goes low but all I see is a clock output on SCL.
> 
>  
> 
>  
> 
> I am using the library from this website.
> 
>  
> 
> http://homepage.hispeed.ch/peterfleury/group__pfleury__ic2master.html
> 
>  
> 
>  
> 
> Any ideas what I am missing?
> 
>  
> 
> Dave.
> 
>  
> 
> 
> 
> [Non-text portions of this message have been removed]
>

Re: [AVR-Chat] Strange issue with I2C master

2013-05-19 by Jim Wagner

Do you have external pullup resistors? Internal pull-ups are around 25K (IIRC) but desired value is under 1.5K.

Jim Wagner

On May 19, 2013, at 2:35 AM, Dave McLaughlin wrote:

> Hi all,
> 
> I have an ATMega328P and trying to use the I2C Master interface but when I
> send the start bit I am seeing a series of what appears to be clocks on the
> SCL line and nothing on the SDA.
> 
> I would expect SDA to be high at the same time as SCL goes hi and then SDA
> goes low but all I see is a clock output on SCL.
> 
> I am using the library from this website.
> 
> http://homepage.hispeed.ch/peterfleury/group__pfleury__ic2master.html
> 
> Any ideas what I am missing?
> 
> Dave.
> 
> [Non-text portions of this message have been removed]
> 
> 



[Non-text portions of this message have been removed]

RE: [AVR-Chat] Strange issue with I2C master

2013-05-19 by Dave McLaughlin

Pullups are on the SDA and SCL and are 10K, which has worked well before on
other designs. This is my first attempt at using I2C with AVR GCC.

I can see the SCL bus initially go low then high and then this clock appears
immediately after.

My init sets the TWBR to 152 with a prescale of 1. This, with a 16Mhz osc,
gives me a 50Khz bus speed which is what I need for this device.

I single step the following line of code and then this clock appears after
it:

           TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);

and then it hangs at this call:

	// wait until transmission completed
	while(!(TWCR & (1<<TWINT)));

I am only using ADC0 and ADC1 for analog input on the same bus but in
another email, John Samperi said that you can do this? The digital IO is
only disabled on PC0 and PC1
Show quoted textHide quoted text
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of Jim Wagner
Sent: 19 May 2013 22:00
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Strange issue with I2C master

Do you have external pullup resistors? Internal pull-ups are around 25K
(IIRC) but desired value is under 1.5K.

Jim Wagner

RE: [AVR-Chat] Re: Strange issue with I2C master

2013-05-19 by Dave McLaughlin

OK. I have it working now.

 

I was calling i2c_start_wait and this for some reason was generating a clock
because it was looping around.

 

Changing to i2c_start it now works.

 

:)

 

 

Cheers

Dave.
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of englsprogeny1
Sent: 19 May 2013 20:54
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] Re: Strange issue with I2C master

 

  

Hi Dave,

Can you give us a code example?

I see that this library is to be used with GCC.

I always use external pullup resistors on my I2C lines.

Is something else trying to write to the DIO used for SDA?

--- In AVR-Chat@yahoogroups.com <mailto:AVR-Chat%40yahoogroups.com> , "Dave
McLaughlin" <dave_mclaughlin@...> wrote:
>
> Hi all,
> 
> 
> 
> I have an ATMega328P and trying to use the I2C Master interface but when I
> send the start bit I am seeing a series of what appears to be clocks on
the
> SCL line and nothing on the SDA.
> 
> 
> 
> I would expect SDA to be high at the same time as SCL goes hi and then SDA
> goes low but all I see is a clock output on SCL.
> 
> 
> 
> 
> 
> I am using the library from this website.
> 
> 
> 
> http://homepage.hispeed.ch/peterfleury/group__pfleury__ic2master.html
> 
> 
> 
> 
> 
> Any ideas what I am missing?
> 
> 
> 
> Dave.





[Non-text portions of this message have been removed]

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.