Exact match. Not showing close matches.
PICList
Thread
'[SX] Best way to address only 4 pins of a port'
2006\01\19@104630
by
Jim Fouchn/a
|
|
This may seem simple, but I was wondering what was the best way to clear the states of only 4 pins on a port w/o disturbing the others.
In my project I'm using Port B (pins 1-3) for an A/D and also pins 4-7 to drive a stepper motor .
Here is the code I'm using now...
SendMotorCommand:
Read HalfSteps + StepIndex, Temp1
RB.7 = 0
RB.6 = 0
RB.5 = 0
RB.4 = 0
RB = RB or Temp1
Return
RelaxMotor:
RB.7 = 0
RB.6 = 0
RB.5 = 0
RB.4 = 0
Return
HalfSteps:Data %00000000
Data %00010000
Data %00110000
Data %00100000
Data %01100000
Data %01000000
Data %11000000
Data %10000000
Data %10010000
Just wondering is there is a better way to address (clear) the states of only 4 pins on a port.Thanks,
Jim
2006\01\19@105834 by Coriolisn/a
|
|
Using the logic operand AND is the most efficient means of clearing a series of bits, RB = RB AND #$0F, would clear bits 4-7, I may have the syntax wrong since I don't use SX/B that much.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=105636#m105641
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)
|
|
Paul,
Without the "#" though. RB = RB AND $0F
Bean.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=105636#m105644
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)
2006\01\19@114047 by Coriolisn/a
|
|
Thanks Bean, that was what I suspected was incorrect.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=105636#m105648
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)
More... (looser matching)
- Last day of these posts
- In 2006
, 2007 only
- Today
- New search...