Sridhar gadda wrote: > I have seen an example program in which the statement ADCR |= > 0x01000000 which starts ADC conversion and ADCR &= ~0x01000000 > stops ADC conversion. The '|' and '&' symbol are compiler specific or No, they're standard C. A statement like "x |= y" means do a logical (bitwise) OR of x and y and store the result in x. The & symbol means logical AND. 0x01000000 is a number with only bit 24 set. You could also (IMO more readably) write it as (1<<24). ~0x1000000 is the same number inversed, so every bit _except_ 24 is set. When you logically OR a bit with 1 the result is always 1 and when you logically OR a bit with 0 the result is unchanged, so the first statement sets bit 24 of ADCR without affecting any of the other bits. When you logically AND a bit with 0 the result is always 0 and when you logically AND a bit with 1 the result is unchanged, so the second statement clears bit 24 of ADCR without affecting any of the other bits. The above code toggles bit 24 of ADCR high then low and leaves the rest of ADCR unchanged which would not be the case if you simply did ADCR=(1<<24);ADCR=0. I recommend you get hold of a good book on C. The C Programming Language by Kernighan and Ritchie is the best IMHO. -- ------------ Alex Holden - http://www.linuxhacker.org ------------ If it doesn't work, you're not hitting it with a big enough hammer
Message
Re: [lpc2000] Hello from New memeber
2004-12-04 by Alex Holden
Attachments
- No local attachments were found for this message.