I’ve been trying to emulate a PS2 controller using a Motorola microcontroller, which I guess is the opposite of what most people on this board are doing. I’m having alot of problems though, when I try sending the appropriate data (idle, x41, x5A, button codes), I get CMD values (x01, x45 instead of x42, and then x5A on later CMD’s when it should be idle). Does anyone have any ideas on what’s going wrong? When not sending any data, I get the expected signals from the PS2 (x01, x42, idle, idle, idle). I was hoping I’m doing something obvious wrong.
It could be that your baudrate is wrong, or that you’ve got some extraneous clock edges that are shifting your data.
Alan KM6VV
I’ve hooked it up to a logic analyzer and don’t see any extra edges shifting data. I’m doing all transfers through the SPI (some motorola serial protocol) in slave mode, so I don’t have to worry about baud rate since it’s from the PS2, right?
Yes, that’s true for a slave. How about the data transition edges? They should not be aligned with or near the clock transitions, as you probably know.
What inputs are being used? Any chance they need pullup resistors? Sometimes there is overshoot, which can be tamed with the usual bus treatments.
Alan KM6VV
Yes, I’ve made sure that transmission lines change on the falling edge and are read by the other component on the rising edge to allow for whatever settle times there may be.
The inputs to the microcontroller are the clock (CLK), attention signal (ATT), and command signal from the PS2 (CMD). The outputs to the PS2 are the data signal (DATA) and acknowledge (ACK). All the signals are normally high, but positive logic during the byte transmissions. The transmission is synchronous 5 bytes to/from (DATA/CMD lines) the PS2, 1 byte at a time followed by an ACK from me to the PS2 to get the next byte.
How would I know if I need pullup resistors? My understanding of it was that they should be used with open collector. From what I see in other posts, some boards will need it while others may not? Would it hurt to add a pullup anyways?
I’m not sure what overshoot is, what are the ‘usual bus treatments’?
Thanks for the help by the way.
Overshoot (or ringing) is when the voltage of a signal goes past the typical 0 & +5 levels associated with logic.
When I implemented SPI for an ARM7 controller (fast driver pins), I saw a lot of ringing on the signal and data lines. Bus termination (pull-ups and/or pull downs) are in order here. Also, small (220?) resistors in in the lines can help to reduce the ringing. Ringing lines can cause false clocks and data.
Alan KM6VV
You said you use SPI with an ARM7 controller, was it to interface with a controller or to interface as a controller to the PS2 like what I’m trying, or something unrelated?
Ok I remember what overshoot is, I don’t think I’m seeing it because I looked at it with a scope and it looked pretty good.
Is there any reason I would be seeing x5a on CMD instead of xff after I send x5a on DATA? It looks like the DATA line is doing something to the CMD line, but I haven’t been able to find any information about that.
My hardware was basically unrelated. I interfaced to 2 '595 and 2 '597 shift register parts. I did both input and output via SPI. I never saw an “echo” such as you describe.
Just a thought, could it possibly be a register thing? Is there a shared register perhaps? Maybe setup of the SPI is in error?
Did you use the manufacture’s #defines or macros for the the pins?
Are you sharing a pull-up resister?
I didn’t like the PS2 timing on another project (PS2 to a PIC on a 'bot, was bit-banging).
Alan KM6VV
I was pretty sure I was doing all the software correctly, I’ve been using the same microcontroller for another class. I also thought that I might not have been using SPI correctly, so I instead am trying to do the transmissions manually, as in shifting in/out bits in my own function instead of using the built-in SPI stuff.
You said you got a PS2 console to PIC working, or PS2 Controller to PIC?
OK, you’re bit-banging as well. I thought I’d remembered that you were using the hardware SPI.
I got my 'bot controller talking to the PS2 controller, although it’s not as good as I’d like. I need to revisit the code, as it seems to be running a little worse then before since I’ve added a lot of other code to the program.
A previous thread on PS2. There is some sample MASTER code in ‘C’ there, and some references.