[sdiy] OT what is _BV (AVR)

dan snazelle subjectivity at hotmail.com
Thu Mar 10 03:30:29 CET 2011


I know a lot of people on here use C on the AVR so i thought someone might be able to answer this question.

Much of the code I have been reading and re-reading for the AVR is made up of lines do things to the registers.


I keep seeing lines that start with _BV which is a command I have not been able to find the meaning of. And then there is an AND command or an OR command and two locations inside a register.



for example:


TCCR2A = _BV (COM2B1)  | _BV (WGM20) ;        //I have found that COM2B1 is bit 5 of the TIMER COUNTER CONTROL REGISTER A and WGM20 is Bit 0
TCCR2B = _BV (CS20) ;              // I have found that CS20 is bit 0 is timer counter control register B
TIMSK2 = _BV (TOIE2);            // I have found that TOIE2 is bit 0 of timer counter 2 interrupt mask register



on the right, you can see my comments about what these registers are.


I am really just wondering what _BV is and what its purpose is.


I am trying to learn by reading code line by line until I understand what each line means.

these lines which relate to accessing the AVR's registers are so far the most complicated part and there is the least amount of info out there on understanding them


anyway, thanks for any HELP






More information about the Synth-diy mailing list