RESOLVED: Checking input pin: Is this valid?
Wurlitzer
Posts: 237
Dumb mistake: Did not have the wc, wz after the DJNZ
This is an assembly code snipit from a routine that generates a clock pulse to an external IC shift register and at a given count (50) should wait until an input pin (2) is low.
The clock to the shift register works perfectly verified by my scope and the logic to only check at count 50 is fine again verified via my scope.
I did not use the Waitpne method as if I never saw the pin low it would wait forever and that is not what I want.
On the input Pin I have a junction of a resistor to Vcc and a variable inductor which gets its other end pulled low at count 50.
What I am attempting to do is look at the number of clock pulses until the input pin drops below the TRUE threshold
What is actually happening is regardless if I, for test purposes, ground pin #2 or pull it High this code always waits the 256 counts before hitting the WriteCircQueue which writes the value of InputCount and now that is always "0"'.
I had originally used pin #1 with the same results but I move it to 2 just in case I had damaged the pin. I had also tried using a Mask variable instead of "#2" with the same results.
NOTE: There is a diode across the inductor to protect the Prop input pin. Via the scope I can also see exactly the normal LR time constant curve.
[noparse][[/noparse]code]<
Main mov InputCount, #256
call #Clockset
cmp ScanCnt, #50 wc,wz,nr
if_ne jmp #skp1 {simply clears the clock signal then jumps to Main}
tstLoop and ina, #2 wc,wz,nr
if_z djnz InputCount, #tstLoop
call #WriteCircQueue>
[noparse][[/noparse]\code]
Post Edited (Wurlitzer) : 6/20/2009 3:16:11 PM GMT
This is an assembly code snipit from a routine that generates a clock pulse to an external IC shift register and at a given count (50) should wait until an input pin (2) is low.
The clock to the shift register works perfectly verified by my scope and the logic to only check at count 50 is fine again verified via my scope.
I did not use the Waitpne method as if I never saw the pin low it would wait forever and that is not what I want.
On the input Pin I have a junction of a resistor to Vcc and a variable inductor which gets its other end pulled low at count 50.
What I am attempting to do is look at the number of clock pulses until the input pin drops below the TRUE threshold
What is actually happening is regardless if I, for test purposes, ground pin #2 or pull it High this code always waits the 256 counts before hitting the WriteCircQueue which writes the value of InputCount and now that is always "0"'.
I had originally used pin #1 with the same results but I move it to 2 just in case I had damaged the pin. I had also tried using a Mask variable instead of "#2" with the same results.
NOTE: There is a diode across the inductor to protect the Prop input pin. Via the scope I can also see exactly the normal LR time constant curve.
[noparse][[/noparse]code]<
Main mov InputCount, #256
call #Clockset
cmp ScanCnt, #50 wc,wz,nr
if_ne jmp #skp1 {simply clears the clock signal then jumps to Main}
tstLoop and ina, #2 wc,wz,nr
if_z djnz InputCount, #tstLoop
call #WriteCircQueue>
[noparse][[/noparse]\code]
Post Edited (Wurlitzer) : 6/20/2009 3:16:11 PM GMT
Comments
is the problem. INA is only good, when used as source, but you use it as destination. It will not read the port, it takes the content of the shadow RAM (which is always 0).
AND two, ina WC, WZ, NR
...
two LONG 2
would help. By the way ... AND ___ NR has it's own opcode, which is
TEST two, ina WC, WZ