
N64 CONTROLLER SERIAL PROTOCOL INTERFACE CODE
I did change the receive code to use the change notification interrupt but I have a new problem now. Do you mean to use something like the change notification on the data signal pin? When you say "enable interrupts at falling edge for clock line" which clock line do you mean? There is no clock signal in the interface, there is only the data signal. (sorry if this post ends up duplicated, my previous attempts to post ended in an unhelpful dialog box and then a blank text box)

Any thoughts on the "right" way to do this would be appreciated. I suspect there is a much more efficient way to do this using some peripheral that I don't know about or knowledge I don't have. No matter what I've done I can't seem to get a consistent sampling of the response bits. I added _RC1=1 / _RC1=0 around the sampling of the data line and looked at it with the LA. I unrolled the loop for polling for the 33*4 sub-bits and the code became very large. Polling to receive bits hasn't worked as well. I can also see a response coming back from the device.
N64 CONTROLLER SERIAL PROTOCOL INTERFACE FULL
After discovering SYSTEMConfigPerformance(80000000L) to tighten up the timing, I verified with a logic analyzer that commands are sent to the gamepad and the shape of the signal looks pretty good (pretty close to 4 us per full bit). To send a 0 sub bit I set _RG15 as an output and set it to '0', to send a '1' I set _RG15 as an input to let it go Z. In order to handle the bidirectional nature, I configured _RG15 as open-drain-enabled. To simplify things, I bit banged commands out to the data line. Based on that a new full bit is signaled by a falling edge on the data line. Bits are encoded as four sub bits ('0', data bit value, data bit value, stop '1') where each sub bit is held for 1 us. The host (pic32) sends an 8-bit (plus one stop bit) command to the controller which responds with a 32-bit (plus one stop bit) result. The N64 gamepad communicates via a serial protocol over a 3 wire connection (3.3v, GND, bidirectional data line). I'm using a PIC32 USB starterkit with I/O expansion board. As a "non-follow-the-tutorial" project I thought I would see if I could interface with an old N64 gamepad.

I'm new to PIC development and need some guidance.

still researching.Doing high-speed bidirectional serial i/o

Thanks for the replies! Research leads me to believe that a PIC with UART will do the trick. I think I'm looking for information on sending digital data, and which type(s) of microcontrollers would be best for the job, but I'm not entirely sure that this is what is necessary. As with the N64 controller, a low bit is signalled by a 3us low followed by 1us high, and a high bit is signalled by 1us low followed by 3us high. The transfer speed is rather fast at around 4us per bit. Communication is initiated by the console sending a 24-bit string to the controller, after which the controller responds with 64-bits of button state and joystick data.Īlthough I first thought that the controller had an internal pull-up resistor (measured 745 ohms), in practice I had to use an external 1K pull-up resistor between the 3.43V rail and the the data line in my prototype interface. This is an active high 3.43V logic signal, using a pull-up resistor to hold the line high, and pulling it low with an open-collector transistor when a low needs to be transmitted. The controller uses one bi-directional data line (Pin 2 - Red) to communicate with the console.
