Microcontroller programming

What are the sbi and cbi functions in microcontroller programming??????????????

westfw9 years ago
Probably "Set Bit in IOreg" and "Clear Bit in IOreg"; that's what they are on an Atmel AVR. Given a bit number (0-7) and the address of an IO register (0-31), they set or clear the bit without bothering other bits in the register. An AVR has many more than 31 I/O registers, and will require more complex instructions to access the registers beyond 31, but for those first registers (typically including the direct IO pin registers) SBI/CBI can do it quicker. IIRC, sbi() and cbi() are also (deprecated) functions/macros defined in avr-gcc that perform the same functions, but do NOT have the restrictions on register address; the exact choice of instructions happens "lower down" in the code generator, and avr-gcc will "do the right thing."
sweetramy (author)  westfw9 years ago
Thanks fr ur comment.... it really helped me