Hello,
After trying for a while, I failed to get these three words together. Do not master the bitmask. Despite the examples and the email. Can someone please help me with this. This is my simple code. The source is from flashForth. The tree words are setBitmask,clearBitmask and testBitmask. Thanks for any help. With kindly regards, Jan $24 constant ddrb $25 constant portb $4c constant spcr $4d constant spsr $4e constant spdr \ bit masks %000100 constant mSS ( PB2 - pin 10 ) %001000 constant mMOSI ( PB3 - pin 11 ) %010000 constant mMISO ( PB4 - pin 12 ) %100000 constant mSCK ( PB5 - pin 13 ) $80 constant mSPIF $40 constant mWCOL : setBitmask ; ( bitmask port -- ) : clrBitmask ; ( bitmask port -- ) : testBitmask ; ( bitmask port -- flag ) : spi.init ( -- ) mSCK ddrb setBitmask \ SCK as output mSCK portb clrBitmask \ clock idles low mMOSI ddrb setBitmask \ MOSI as output mMISO ddrb clrBitmask \ MISO as input mMISO portb setBitmask \ activate pull -up on MISO mSS ddrb setBitmask \ SS as output mSS portb setBitmask \ deselect $51 spcr c! \ enable as master with cpolarity 0, cphase 0, fosc /16 $00 spsr c! \ SPI2X =0 for fosc /16 spsr c@ drop spdr c@ drop \ will clear SPIF ; : spi.wait ( -- ) begin mSPIF spsr testBitmask until ; > Op 17 jun. 2019, om 21:31 heeft Matthias Trute <mtr...@web.de> het volgende > geschreven: > > Hi Jan, > >> I need to do a bitmask on register. > > The simplest operations are the ones documented > in the source file > > \ Use it this way: > \ PORTD 7 portpin: PD.7 ( define portD pin #7) > \ PD.7 high ( turn portD pin #7 on, i.e. set it high- > level) > \ PD.7 low ( turn portD pin #7 off, i.e. set it low- > level) > \ PD.7 <ms> pulse ( turn portD pin #7 for <ms> high and low) > \ the following words are for "real" IO pins only > \ PD.7 pin_output ( set DDRD so that portD pin #7 is output) > \ PD.7 pin_input ( set DDRD so that portD pin #7 is input) > \ PD.7 pin_high? ( true if pinD pin #7 is high) > \ PD.7 pin_low? ( true if pinD pin #7 is low) > \ > > These word use only one bit. > >> In bitnames.frt there is a word bitmask: How can I use it to do >> the two actions above? > > Note that the hex coding is used (a single F means $f) > > \ 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 ) > > A bitmask operates on all bits that are 1 in the bitmask. All others > are unaffected, c! would overwrite all bits. > > Matthias > > _______________________________________________ > Amforth-devel mailing list for http://amforth.sf.net/ > Amforth-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/amforth-devel _______________________________________________ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel