blueroomelectronics Well-Known Member Feb 12, 2009 #1 What is the C18 equivalent to the assembly instruction BTG (Bit toggle)?
futz Active Member Feb 12, 2009 #2 blueroomelectronics said: What is the C18 equivalent to the assembly instruction BTG (Bit toggle)? Click to expand... Exclusive OR (^) with a mask of your target bit/byte/word/whatever. I don't have a PIC example handy, but here's an ARM sample. The code is used to toggle two bits for a piezo beeper to drive it antiphase. Code: IOPIN0 ^= 0x00003000; Last edited: Feb 12, 2009
blueroomelectronics said: What is the C18 equivalent to the assembly instruction BTG (Bit toggle)? Click to expand... Exclusive OR (^) with a mask of your target bit/byte/word/whatever. I don't have a PIC example handy, but here's an ARM sample. The code is used to toggle two bits for a piezo beeper to drive it antiphase. Code: IOPIN0 ^= 0x00003000;
P Pommie Well-Known Member Most Helpful Member Feb 12, 2009 #3 Both, LATBbits.LATB7=!LATBbits.LATB7; and LATB^=128; compile to a BTG. Edit, Rather shockingly, LATB=LATB^128; results in 3 instruction. And that is with full optimization. Mike. Last edited: Feb 12, 2009
Both, LATBbits.LATB7=!LATBbits.LATB7; and LATB^=128; compile to a BTG. Edit, Rather shockingly, LATB=LATB^128; results in 3 instruction. And that is with full optimization. Mike.
blueroomelectronics Well-Known Member Feb 19, 2009 #4 Thanks guys, starting to get the hang of C18, C30.