SX/B low and high commands
Peter Verkaik
Posts: 3,956
The SX/B command high ra compiles into
· MOV W,#$1F···················· ;· high ra
· MOV M,W······················
· MOV !RA,#0···················
· MOV RA,#$FF
If ra was already set to all outputs there is no problem.
If ra however was set to inputs, but the latch holds zeroes,
then changing to outputs makes the pins low
and the mov ra,#$FF makes the pin high.
So there is a (possible) glitch.
I think the order should be
· MOV RA,#$FF
· MOV W,#$1F···················· ;· high ra
· MOV M,W······················
· MOV !RA,#0···················
If the pins are already outputs, the pins get the right value.
If the pins were inputs, the pins also get the right value, but without a glitch.
So the order should be: set latch, then set direction.
regards peter
· MOV W,#$1F···················· ;· high ra
· MOV M,W······················
· MOV !RA,#0···················
· MOV RA,#$FF
If ra was already set to all outputs there is no problem.
If ra however was set to inputs, but the latch holds zeroes,
then changing to outputs makes the pins low
and the mov ra,#$FF makes the pin high.
So there is a (possible) glitch.
I think the order should be
· MOV RA,#$FF
· MOV W,#$1F···················· ;· high ra
· MOV M,W······················
· MOV !RA,#0···················
If the pins are already outputs, the pins get the right value.
If the pins were inputs, the pins also get the right value, but without a glitch.
So the order should be: set latch, then set direction.
regards peter
Comments
Good point.
The pins could possibly be low for 1 cycle before they went high. I will change that in the next revision.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
There are only two guaranteed ways to become weathy.
Spend less than you make.
Make more than you spend.
·
· MOV W,#$0F···················· ;· high ra.0
· MOV M,W······················
· MOV !RA,W····················
· MOV __PARAM1,W···············
· CLRB __PARAM1.0··············
· MOV W,#$1F···················
· MOV M,W······················
· MOV !RA,__PARAM1·············
· SETB ra.0··
I believe the first 3 instructions make all ra pins inputs
because w holds $0F with the 3rd instruction. Only pin 0 should be affected.
The 4th instruction makes me believe the current direction register value is read
and stored in __PARAM1. I thought that mode value $1F was to be used to read direction register.
Please correct me if I am wrong about that (code was compiled for sx48).
The SETB ra.0 should be the first instruction (to avoid possible glitch)
Edit: just downloaded the latest sxkey manual. Mode $0F is indeed read for SX48/52,
so only pin 0 is affected, as it should.
regards peter
Post Edited (Peter Verkaik) : 9/16/2006 12:08:04 AM GMT