The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.
SMBus or i2c error - magzky02 - Aug 17 22:39:11 2008
Hello forumers, I am using MSP430F1610 to communicate with i2c/SMBus
devices. It runs OK when the the i2c devices are working fine. But if
the device is not working/defective/not responding, my code hangs. How
do you know that there is error in i2c communication? As for now, i
place a counter to exit if the device is not responding after some
counts.
while (I2CDCTL & I2CBUSY);
I2CNDAT = 0x01;
I2CSA = 0x18; U0CTL |= MST;
I2CTCTL |= I2CSTT+I2CSTP+I2CTRX; // write
while ((I2CIFG & TXRDYIFG) == 0x0) // it hangs here if no counter
{cnt++; if (cnt > 5000){tj_id = 0x30; reak;}}
I2CDRB = 0xFE; // manufacturer id
while ((I2CTCTL & I2CSTP) == I2CSTP);
thanks,
mago
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )
Re: SMBus or i2c error - Joerg - Aug 21 18:31:00 2008
magzky02 wrote:
> Hello forumers, I am using MSP430F1610 to communicate with i2c/SMBus
> devices. It runs OK when the the i2c devices are working fine. But if
> the device is not working/defective/not responding, my code hangs. How
> do you know that there is error in i2c communication? As for now, i
> place a counter to exit if the device is not responding after some
> counts.
>
> while (I2CDCTL & I2CBUSY);
> I2CNDAT = 0x01;
> I2CSA = 0x18; U0CTL |= MST;
> I2CTCTL |= I2CSTT+I2CSTP+I2CTRX; // write
> while ((I2CIFG & TXRDYIFG) == 0x0) // it hangs here if no counter
> {cnt++; if (cnt > 5000){tj_id = 0x30; reak;}}
> I2CDRB = 0xFE; // manufacturer id
> while ((I2CTCTL & I2CSTP) == I2CSTP);
>
Ok, since nobody answered let me just mention what I've observed but I
am using SPI a lot, no I2C in many years. So I am not an expert on this.
Anyhow, I2C devices seem to hang at times and what people did was this:
a. Time-out, just like you are planning to do. IIRC a few tens of msec.
b. Issueing some stop commands.
c. Holding SCK and SDA low for a while, hoping that this will pull the
recalcitrant device out of the mud.
--
Regards, Joerg
http://www.analogconsultants.com/
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )
Re: SMBus or i2c error - Joerg - Aug 21 18:51:39 2008
magzky02 wrote:
> Hello forumers, I am using MSP430F1610 to communicate with i2c/SMBus
> devices. It runs OK when the the i2c devices are working fine. But if
> the device is not working/defective/not responding, my code hangs. How
> do you know that there is error in i2c communication? As for now, i
> place a counter to exit if the device is not responding after some
> counts.
Just one more remark. It may be good to find out why this hang-up
happens. Connect a scope to the I2C lines, look for overshoots,
undershoots, ringing, spikes, EMI, the usual. Try to find out if some
big load is being switched when it happens or if a cell phone is being
turned on. Maybe a little AC termination is needed on those lines.
--
Regards, Joerg
http://www.analogconsultants.com/
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )
Re: Re: SMBus or i2c error - mago Umandam - Aug 22 8:32:28 2008
Thanks Joerg. Seems the best way is to time it out. Because my aplication i=
s a tester, it must be able to handle cases like this where the i2c slave d=
evice doesnt respond.
=A0
regards,
mago
--- On Fri, 8/22/08, Joerg
wrote:
From: Joerg
Subject: [msp430] Re: SMBus or i2c error
To: m...@yahoogroups.com
Date: Friday, August 22, 2008, 6:30 AM
magzky02 wrote:
> Hello forumers, I am using MSP430F1610 to communicate with i2c/SMBus=20
> devices. It runs OK when the the i2c devices are working fine. But if=20
> the device is not working/defective/ not responding, my code hangs. How=20
> do you know that there is error in i2c communication? As for now, i=20
> place a counter to exit if the device is not responding after some=20
> counts.=20
>=20
> while (I2CDCTL & I2CBUSY);=20
> I2CNDAT =3D 0x01;
> I2CSA =3D 0x18; U0CTL |=3D MST;=20
> I2CTCTL |=3D I2CSTT+I2CSTP+ I2CTRX; // write
> while ((I2CIFG & TXRDYIFG) =3D=3D 0x0) // it hangs here if no counter
> {cnt++; if (cnt > 5000){tj_id =3D 0x30; reak;}}=20
> I2CDRB =3D 0xFE; // manufacturer id=20
> while ((I2CTCTL & I2CSTP) =3D=3D I2CSTP);=20
>=20
Ok, since nobody answered let me just mention what I've observed but I=20
am using SPI a lot, no I2C in many years. So I am not an expert on this.=20
Anyhow, I2C devices seem to hang at times and what people did was this:
a. Time-out, just like you are planning to do. IIRC a few tens of msec.
b. Issueing some stop commands.
c. Holding SCK and SDA low for a while, hoping that this will pull the=20
recalcitrant device out of the mud.
--=20
Regards, Joerg
http://www.analogco nsultants. com/
=20
=20=20=20=20=20=20
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )