bulkhead
09-11-2007, 10:39 AM
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).
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
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