nesdev.com
http://forums.nesdev.com/

Controller port clocking
http://forums.nesdev.com/viewtopic.php?f=9&t=14775
Page 1 of 1

Author:  johey [ Sat Sep 03, 2016 1:54 pm ]
Post subject:  Controller port clocking

Trying to build a custom uC based controller adapter for the NES (American model). Though I'm surprised over the clock pulse I get from the NES. First, it looks to be active low in contrast to reference diagrams, but most strangely the clock pulse is very short. About 1 us.

Attachment:
20160903_223738.jpg
20160903_223738.jpg [ 3.01 MiB | Viewed 1893 times ]


Channel 1 is the latch and channel 2 is the clock pulse. What is this about? Should it be like this? When is the data read? On rising edge? I'm in trouble with this timing.

Author:  lidnariq [ Sat Sep 03, 2016 2:07 pm ]
Post subject:  Re: Controller port clocking

The clock pulse is only true (= low) for the (usually) 1/(1.789MHz) that the address bus is exactly $4016 (Player 1) or $4017 (Player 2).

The system uses transparent latches instead of edge-triggered registers; transparency closes on the falling edge of M2 (which should be approximately the same time as the rising edge of JOYn/OE, maybe a little earlier)

It's worth noting that the NES's joypad inputs are isolated from the CPU data bus; you have all the time from the rising edge until shortly after the next falling edge to drive the correct new value, and you don't need to only emit while JOYn/OE is low (this what the 74'368 on the mainboard is for)

You might find the following pages on the wiki useful:
nesdevwiki:CPU pin out and signal description
nesdevwiki:Standard controller
as well as the 6502 datasheet. ( http://6502.org/documents/datasheets/mos/ )

Author:  rainwarrior [ Sat Sep 03, 2016 2:18 pm ]
Post subject:  Re: Controller port clocking

Also might be worth noting that the clocks themselves come from software, so the timing is highly variable from game to game. Some won't read them all at once, some won't even read all of them, some will read extra bits. It's also very common for games to re-read the whole thing (i.e. latch and start again) three or four times in a single frame.

Author:  johey [ Sat Sep 03, 2016 3:09 pm ]
Post subject:  Re: Controller port clocking

Thanks for the informative replies!

When I try sending data on the data pin, it looks like the NES is pulling it low. Is that an expected behavior?

Author:  lidnariq [ Sat Sep 03, 2016 3:18 pm ]
Post subject:  Re: Controller port clocking

There should only be a weak pullup resistor on the input side of the 74'368 on the mainboard.

If you're seeing otherwise ... uh, are you connected to the right place?

Author:  johey [ Sat Sep 03, 2016 5:25 pm ]
Post subject:  Re: Controller port clocking

Indeed I wasn't connecting it correctly. :oops:

Author:  johey [ Sun Sep 04, 2016 9:37 am ]
Post subject:  Re: Controller port clocking

Just want to say thank you for all valuable input. I successfully made it working after some trial n error.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/