NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » waht dose |= do

January 24, 2012
by scootergarrett
scootergarrett's Avatar

its reading in from a pin for the temperature sensor

ADCSRA |= (1<<ADSC);

January 25, 2012
by JimFrederickson
JimFrederickson's Avatar

I would suggest going to google.com and searching for:

"c language reference manual 007–0701–150"

Download the PDF Version to your computer for a reference. (It is, I believe, the basic c Language Reference.)

For more specific information for the AVR Environment I generally search for:

"avr-gcc ???"

where "???" is whatever I want to find.

Often though it takes a lot of 'sorting through things' to find what is helpful.

In regards to your current question...

I was going to answer, but now I am not...

Ralph has already answered that particular question VERY WELL...

So in this forum, search for "questions about setting bits". (The search for the forum is the top right corner of the Web page...)

The first link that shows up, at least that is what is for me, is a link to a post that was made on May 25, 2011.

Ralph's answer is very good, and pretty much all-encompassing...

October 21, 2012
by scootergarrett
scootergarrett's Avatar

I think search engines get caught up with series of characters like “|=” you can’t ever find this thread by searching |=

Now I know thanks

October 21, 2012
by Ralphxyz
Ralphxyz's Avatar

That is why JimFrederickson told you to search for "in this forum, search for questions about setting bits"!!

And yes the the search engine does not return anything for |=, can you imagine how many times that those two characters have been posted in this forum. If it had returned anything there would have have been 7,976,456 threads returned with |= and you would have had to "search through them for questions about setting bits".

So just doing what you were told (which I know is hard to do) would have saved you 10 months of searching.

Ralph

October 22, 2012
by Rick_S
Rick_S's Avatar

The Pipe symbol | means Logical OR. The equal symbol is assignment. You may have an instance where you want to make sure certain bits in a register in the MCU are set to logical 1 to configure a port or setup the ADC. This is where this comes in place.

A |= B, is a short hand method of saying A=A|B.

As for info on what OR does, the NK guide has a pretty good "Lesson" on this toward the back.

Rick

Post a Reply

Please log in to post a reply.

Did you know that Pulse Width Modulation (PWM) can be used to control the speed of a motor digitally? Learn more...