Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | 68HC12 | NewbieQuestion about I2C


Advertise Here

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

NewbieQuestion about I2C - sleidiman - Jun 15 3:07:00 2005

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




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


Re: NewbieQuestion about I2C - Uwe Arends - Jun 15 4:22:00 2005

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


______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


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

Re: NewbieQuestion about I2C - sleidiman - Jun 15 7:56:00 2005

> 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 :-)




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

Re: Re: NewbieQuestion about I2C - Uwe Arends - Jun 15 8:34:00 2005

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


______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


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

Re: NewbieQuestion about I2C - sleidiman - Jun 15 9:27:00 2005

> 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!




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

Re: Re: NewbieQuestion about I2C - Uwe Arends - Jun 15 9:39:00 2005

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




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

Re: NewbieQuestion about I2C - sleidiman - Jun 15 9:55:00 2005

> 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




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