Toggling a pin by writing to the PIN register works on most of the NEWER processors, but not all of them. Does work on m48/88/168. It's a neat trick. It is documented, but you have to be looking for it. -carl At 12:33 PM 6/12/2005, you wrote: >Hello, > >You may be able to toggle a port bit by writing a 1 to the corresponding >PINx bit. I've not seen it documented anywhere except in the m2560 document. >You might want to try it to see if it works on all AVR processors. > >For PORTn and BITx it would be, I think... > >tgl_bit: sbi PINn,BITx >ret > >Jim > >----- Original Message ----- >From: "Mark Jordan" <mark@cpovo.net> >To: <AVR-Chat@yahoogroups.com> >Sent: Sunday, June 12, 2005 5:55 AM >Subject: Re: [AVR-Chat] Bit logic... > > > > > > Another way of toggling a PORT bit: > > > > > > tgl_bit: sbis PORTC, BIT > > rjmp sbi_bit > > > > clr_bit: cbi PORTC, BIT > > ret > > > > set_bit: sbi PORTC, BIT > > ret > > > > > > Mark > > On 12 Jun 2005 at 1:58, Roy E. Burrage wrote: > > > > > > > > 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 > > > > > >
Message
Re: [AVR-Chat] Bit logic...
2005-06-13 by Henry Carl Ott
Attachments
- No local attachments were found for this message.