View Full Version : Changing single register bit
cwkoehler
07-30-05, 02:50 PM
Hello,
How do you change a single hardware register bit from a 1 to a 0 or vise versa (say a Timer control register) using Isomax on the IsopodX with version 0.6 installed?
Thanks in advance
nmitech
08-01-05, 11:00 AM
Set bit,
"address" @ "nnnn" OR "address" !
Fetch the current data from the address,
"address" @
then logical "1" OR the n-bit you want to set,
"nnnn" OR
and store back to the address,
"address" !
Clear bit,
"address" @ "nnnn" AND "address" !
Fetch the current data from the address,
"address" @
then logical "0" AND the n-bit you want to clear,
"nnnn" AND
and store back to the address,
"address" !
RMDumse
08-01-05, 05:15 PM
The OR and AND and XOR methods require considerable of stack manipulation so we made an even faster way to set or clear individual bits in the IsoMax(TM) language as well called Trinaries. (Trianries because they take three inputs: two masks and an address.)
Here for example are a few words I used in a program to quickly set or clear a port line used in a shift register application.
DEFINE CMD-LO
SET-MASK 00 CLR-MASK 02 AT-ADDR 0FB1 807OFF + FOR-OUTPUT EEWORD
DEFINE CMD-HI
SET-MASK 02 CLR-MASK 00 AT-ADDR 0FB1 807OFF + FOR-OUTPUT EEWORD
DEFINE ATT-LO
SET-MASK 00 CLR-MASK 04 AT-ADDR 0FB1 807OFF + FOR-OUTPUT EEWORD
DEFINE ATT-HI
SET-MASK 04 CLR-MASK 00 AT-ADDR 0FB1 807OFF + FOR-OUTPUT EEWORD
DEFINE CLK-LO
SET-MASK 00 CLR-MASK 08 AT-ADDR 0FB1 807OFF + FOR-OUTPUT EEWORD
DEFINE CLK-HI
SET-MASK 08 CLR-MASK 00 AT-ADDR 0FB1 807OFF + FOR-OUTPUT EEWORD
DEFINE ACK-LO
SET-MASK 00 CLR-MASK 10 AT-ADDR 0FB1 807OFF + FOR-OUTPUT EEWORD
DEFINE ACK-HI
SET-MASK 10 CLR-MASK 00 AT-ADDR 0FB1 807OFF + FOR-OUTPUT EEWORD
CMD-LO clears the PA1 line and CMD-HI sets it. ATT-LO and ATT-HI work on PB2. CLK-LO and CLK-HI work on PB3, and so on. 807OFF is a constant defined to be 0 if using a 803/805 based processor (IsoPod(TM), PlugaPod(TM) etc.) and 400 if using a 807 based processor (ServoPod(TM), etc.)
vBulletin v3.0.7, Copyright ©2000-2012, Jelsoft Enterprises Ltd.