Hello Jan,

> I need to do a  bitmask on register.
>
> These are the constants, and mask
>
> $24 constant ddrb
> $25 constant portb
>
> \ bit masks
> %000100 constant mSS ( PB2 )
> %100000 constant mSCK ( PB5 )
>
> I wont 
> 1. to set the bits in ddrb with the bitmask mSS
> 2. to clear bits in portb with the bitmask mSCK
>
> In bitnames.frt there is a word bitmask: How can I use it to do
> the two actions above?
>
> This is mor as a learning to understand working with bitmask.
>
> Thanks for any help.

There are only 4 lines of text in amforth/trunk/avr8/lib/bitnames.frt

> \ multi bit operation
> \ PORTD F bitmask: PD.F  ( define the lower nibble of port d )
> \ PD.F pin@              ( get the lower nibble bits )
> \ 5 PD.F pin!            ( put the lower nibble bits, do not change the 
> others )


There is a functional example on this page
http://amforth.sourceforge.net/Projects/ClockWorks/08_timezones.html

see "Code Details" and therein "Pins to select timezone"

Well, in the end there are only 3 important lines:


#include bitnames.frt
\ define bits 0 and 1 of PORTA as a bitmask named _tz
PORTA $03 bitmask: _tz

\ set the pins as "input"
_tz pin_input


\ read the pins --- they are conncted to pullup resistors
\ through switches
_tz pin@

the result is either 0 1 2 or 3 in this particular case,
depending on which of the two bits read as "1".

Hope this helps,
Erich



-- 
May the Forth be with you ...


_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to