Am I using 'waitpne' correctly (ASM)? (resolved)
bulkhead
Posts: 405
Here is my code (a part of it) for attempting to read a playstation controller's signal going to a playstation console. The console sends a clock signal on clkPin and puts bits onto cmdPin, while it receives data from the controller on datPin. 'cmdPin' 'datPin' and 'clkPin' are pin masks, so for example, for clk line on pin 3, clkPin = %0000...0100, etc. I'm trying to monitor both the cmd bytes and data bytes sent between the playstation controller and the console, so the propeller must "wait" for the clock given by the console.
This code is supposed to gather 1 byte each of cmd (going to controller) and data (from controller) and store in 'psxIn' (using the first 16 bits to hold both bytes).
The problem with my code is that it doesn't return any data that is usable. It appears to be returning random pin states, but when I run viewport's 20mhz LSA, I can see the signal perfectly fine. The time between half clock cycles is roughly 1us, so at 50ns per instruction, my program should be running fast enough to see what's going on.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm new to the propeller!
Post Edited (bulkhead) : 9/11/2007 6:05:51 AM GMT
This code is supposed to gather 1 byte each of cmd (going to controller) and data (from controller) and store in 'psxIn' (using the first 16 bits to hold both bytes).
readtxrxloop waitpne clkPin, clkPin 'wait for clk to go LOW <----is this correct? test cmdPin, ina wc 'store CMD bits in psxOut rcr psxOut, #1 waitpne 0, clkPin 'wait for clk to go HIGH <----is this correct? {{mov time, cnt 'half us delay add time, delay waitcnt time, #0 }} test datPin, ina wc 'store DAT bits in psxIn rcr psxIn, #1 djnz reps, #readtxrxloop shr psxOut, #16 'combine psxOut and psxIn into psxIn shr psxIn, #24 or psxIn, psxOut 'psxIn: bits 0-7 = psxIn bits 8-15=psxOut
The problem with my code is that it doesn't return any data that is usable. It appears to be returning random pin states, but when I run viewport's 20mhz LSA, I can see the signal perfectly fine. The time between half clock cycles is roughly 1us, so at 50ns per instruction, my program should be running fast enough to see what's going on.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm new to the propeller!
Post Edited (bulkhead) : 9/11/2007 6:05:51 AM GMT
Comments
See the operator |<
If you are going to show your code it helps if the CONS and VARS etc are shown too but I'm guessing this is the problem.
*Peter*
WAITPNE 0,...
incorrect. You have to give an ADDRESS of a zero. I mostly define two DAT cells
ZERO LONG 0
ONE LONG 1
for generall use in my programs...
works fine the way it was, and the second one should have been
where clkPin is a mask for the clk pin.
Anyways, I have my program reading signals correctly now! Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm new to the propeller!