NewbieQuestion about I2C

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

NewbieQuestion about I2C

sleidiman
Hello!

(I´ve posted this question on www.freegeeks.net, but I didn´t
receive
an answer)

An absolut NewbieQuestion:

I want to measure temperature with DS1721 (Dallas Maxim). That´s
why i
have to work with I2C. Now, I have problems with the protocol.
First I want to send the Adress to the Sensor.
Here my example:

while((IBSR&0x20)==0x00);
{
}
IBCR=0xB0;
IBDR=0x90; /*Sensor Adress*/
while((IBSR&0x80)==0x00);
{
}

(I know, it is not very professional but it should only work for now)
Must I shift the bits out of the DataRegisters, or does it work in
this example? When I have to shift the Bits, can you tell me, how it
functions and can you give me an example?

Greetings




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/68HC12/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply | Threaded
Open this post in threaded view
|

Re: NewbieQuestion about I2C

Uwe Arends
sleidiman, (what kind of man ist that :o) ??)

> while((IBSR&0x20)==0x00);

Shouldn't this read:
    while((IBSR&0x20)!=0x00);
IBB will be SET if the bus is busy, so you want to
wait for it to clear.

> {
> }

what are these for?

> IBCR=0xB0;
> IBDR=0x90; /*Sensor Adress*/
> while((IBSR&0x80)==0x00);
> {
> }

again, what are the braces for?

> (I know, it is not very professional but it should only
> work for now)
> Must I shift the bits out of the DataRegisters, or does it
> work in this example? When I have to shift the

if you change the first while loop to wait for IBB to clear,
this code should work perfectly.

hth
-uwe



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/68HC12/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: NewbieQuestion about I2C

sleidiman
> sleidiman, (what kind of man ist that :o) ??)
It´s a creative fantasy-name. You don´t like it?!
[Furthermore, I din´t want to use a nickname of a famous trademark
:-)
Look here: http://www.heise.de/newsticker/meldung/60586
It´s just in german; Sorry!]

> Shouldn't this read:
> while((IBSR&0x20)!=0x00);
> IBB will be SET if the bus is busy, so you want to
> wait for it to clear.
Hmm No, that´s wrong, I think. The IBSR is just a Status Register
which is read-only. I wanted to compare the result of the bit by bit
addition with 0x00. When the a start signal is detected the IBB-Bit is
1, then the bus is busy. When a stop signal is detected, IBB is
cleared.

> > {
> > }
> again, what are the braces for?
Okay, the braces are useless. You´re right! I thought it looks
better :-)

> > Must I shift the bits out of the DataRegisters, or does it
> > work in this example? When I have to shift the

Okay, thus I don´t need to shift the bits (to the bus)?!?
That´s great!!!
Another question:
There is only 1 Data Register in the I2c-Module. When i received 1
byte, i have to save this byte in an another register to receive the
second byte. It is right?

> hth
> -uwe

tal
sleidiman :-)




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/68HC12/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: Re: NewbieQuestion about I2C

Uwe Arends
Sleidiman,

> > sleidiman, (what kind of man ist that :o) ??)
> It?s a creative fantasy-name. You don?t like it?!

No, it's ok, I was just curious and maybe trying to be funny,
hence the smiley.

> [Furthermore, I din?t want to use a nickname of a famous trademark
> :-)
> Look here: http://www.heise.de/newsticker/meldung/60586
> It?s just in german; Sorry!]

the one or the other four letter word comes to mind when reading
stuff like that.

> > Shouldn't this read:
> > while((IBSR&0x20)!=0x00);
> > IBB will be SET if the bus is busy, so you want to
> > wait for it to clear.
> Hmm No, that?s wrong, I think. The IBSR is just a Status Register
> which is read-only. I wanted to compare the result of the bit by bit
> addition with 0x00. When the a start signal is detected the IBB-Bit is
> 1, then the bus is busy. When a stop signal is detected, IBB is
> cleared.

IBB (bit5, 0x20) is one, if the bus is busy, correct.
Thus "while((IBSR&0x20)==0x00);", like you had it,
waits for the bus to become busy, the opposite of what
one should do prior to using the bus, so I definitely
think it should be "while((IBSR&0x20)!=0x00);"

> > > {
> > > }
> > again, what are the braces for?
> Okay, the braces are useless. You?re right! I thought it looks
> better :-)

curly braces are cute, sure. ;o)

> Another question:
> There is only 1 Data Register in the I2c-Module. When i received 1
> byte, i have to save this byte in an another register to receive the
> second byte. It is right?

Yup, right! Preferably in memory.

hth
-uwe




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/68HC12/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: NewbieQuestion about I2C

sleidiman
> the one or the other four letter word comes to mind when reading
> stuff like that.
Oh, is it right, you´re german? Me too alternatively I am! That´s why,
my English is so bad! Sorry!
 
> IBB (bit5, 0x20) is one, if the bus is busy, correct.
> Thus "while((IBSR&0x20)==0x00);", like you had it,
> waits for the bus to become busy, the opposite of what
> one should do prior to using the bus, so I definitely
> think it should be "while((IBSR&0x20)!=0x00);"

I believe, you´re right.
"while((IBSR&0x20)!=0x00);" --> While the bus is busy, do nothing!
That´s the translation of your code-example, right?

Thanks a lot!




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/68HC12/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: Re: NewbieQuestion about I2C

Uwe Arends
Sleidiman,

> > the one or the other four letter word comes to mind when reading
> > stuff like that.
> Oh, is it right, you?re german? Me too alternatively I am! That?s why,
> my English is so bad! Sorry!

yup, right. Alternatively german?, what's the other alternative(s)? :o)

> > IBB (bit5, 0x20) is one, if the bus is busy, correct.
> > Thus "while((IBSR&0x20)==0x00);", like you had it,
> > waits for the bus to become busy, the opposite of what
> > one should do prior to using the bus, so I definitely
> > think it should be "while((IBSR&0x20)!=0x00);"
>
> I believe, you?re right.
> "while((IBSR&0x20)!=0x00);" --> While the bus is busy, do nothing!
> That?s the translation of your code-example, right?

Exactly!

> Thanks a lot!

Bitte sch?n!
-uwe




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/68HC12/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply | Threaded
Open this post in threaded view
|

Re: NewbieQuestion about I2C

sleidiman
> yup, right. Alternatively german?, what's the other alternative(s)? :o)
Argh, you´ve missunderstood me. I lay the blame on my bad english :-)

> Exactly!
>
>
> Bitte schön!

And i become almost desperate, with my English.
Herrlich! :-)

-bfn-
sleidiman






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/68HC12/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/