Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Bit logic...

2005-06-12 by Roy E. Burrage

I often have to toggle a bit and this is about as short and elegant as I've been able to do with the AVR.


Toggle_A1: ; Toggles PB0 (A1) output state
LDI T1,1 ; Set bit 0 in T1
IN T2,PORTB
EOR T2,T1 ; XOR T1 and Port B (T2) to toggle PB0
OUT PORTB,T2
RET

This routine is called from the main program and could be performed a couple of other ways, but not anything shorter that I can see.

With the 8x31/32 series we had the CPL operation. With the er, uh, those other guys...we have BTG.

Anyone know of a shorter means, code wise, of doing this? Am I missing something, like a single operation?


REB

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.