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.
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.
Controller port clocking
Moderator: Moderators
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/ )
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/ )
- rainwarrior
- Posts: 8734
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
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.
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?
When I try sending data on the data pin, it looks like the NES is pulling it low. Is that an expected behavior?
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?
If you're seeing otherwise ... uh, are you connected to the right place?
Re: Controller port clocking
Indeed I wasn't connecting it correctly.
Re: Controller port clocking
Just want to say thank you for all valuable input. I successfully made it working after some trial n error.