It is currently Mon Dec 11, 2017 4:31 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Controller port clocking
PostPosted: Sat Sep 03, 2016 1:54 pm 
Offline

Joined: Fri Aug 26, 2016 3:42 am
Posts: 8
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 1131 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.


Top
 Profile  
 
PostPosted: Sat Sep 03, 2016 2:07 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6503
Location: Seattle
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/ )


Top
 Profile  
 
PostPosted: Sat Sep 03, 2016 2:18 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5886
Location: Canada
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.


Top
 Profile  
 
PostPosted: Sat Sep 03, 2016 3:09 pm 
Offline

Joined: Fri Aug 26, 2016 3:42 am
Posts: 8
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?


Top
 Profile  
 
PostPosted: Sat Sep 03, 2016 3:18 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6503
Location: Seattle
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?


Top
 Profile  
 
PostPosted: Sat Sep 03, 2016 5:25 pm 
Offline

Joined: Fri Aug 26, 2016 3:42 am
Posts: 8
Indeed I wasn't connecting it correctly. :oops:


Top
 Profile  
 
PostPosted: Sun Sep 04, 2016 9:37 am 
Offline

Joined: Fri Aug 26, 2016 3:42 am
Posts: 8
Just want to say thank you for all valuable input. I successfully made it working after some trial n error.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot], Ice Man, zxbdragon and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group