View Full Version : Am I using 'waitpne' correctly (ASM)? (resolved)

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

Peter Jakacki
09-11-2007, 12:19 PM
waitpne requires a bit mask for the pins you are monitoring so you cannot supply a pin number from 0-31 you must convert this to a bitmask. Likewise with "test".

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.


09-11-2007, 12:51 PM
If pin and masks are set correctly, then there is still
incorrect. You have to give an ADDRESS of a zero. I mostly define two DAT cells
for generall use in my programs...

09-11-2007, 01:03 PM
Sorry, I guess I should name my variables more carefully, but 'clkPin' is actually a mask for clk pin, and so are all of the others. I think I got it now, it seems like the first line

waitpne clkPin, clkPin 'wait for clk to go LOW

works fine the way it was, and the second one should have been

waitpeq clkPin, clkPin 'wait for clk to go HIGH

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!