It is currently Wed Mar 21, 2018 2:21 am

 All times are UTC - 7 hours

 Page 1 of 1 [ 7 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: CPU and PPU clock mathPosted: Sun Apr 26, 2015 6:28 pm

Joined: Sun Apr 05, 2015 7:16 am
Posts: 4
I've read[1] that the NES PPU (NTSC/2C02) is 3 times the speed of the NES CPU.

According to the wiki:

The NES CPU operates at a speed of 21.477272 MHz / 12 = 1789773Hz.
The NES PPU operates at a speed of 21.477272 MHz / 4 = 5369318Hz.

If we take the CPU speed and run the "3 times slower than the PPU" rule:

1789773 * 3 = 5369319hz.

This is 1hz behind the actual PPU speed since 5369319hz != 5369318Hz.

Could this be a big issue if emulator logic is expecting that the PPU clock is 1789773Hz * 3, vs trying to emulate the actual clock rate of 5369319?

[1] http://wiki.nesdev.com/w/index.php/Clock_rate

Top

 Post subject: Re: CPU and PPU clock mathPosted: Sun Apr 26, 2015 7:04 pm

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3016
Location: Tampere, Finland
All of those numbers are rounded, so there's no 1 Hz difference in reality. 3 PPU clocks is always equivalent to 1 CPU clock because both clocks are based on the same master clock. Also note that the real clock frequency is never exactly what is advertised, for example on the 21.47 MHz clock you can see a +-40 Hz tolerance in the page you linked.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi

Top

 Post subject: Re: CPU and PPU clock mathPosted: Sun Apr 26, 2015 8:09 pm

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19783
Location: NE Indiana, USA (NTSC)
Thefox is right about rounding. If you don't want rounding, you'll need to stay in the rational number domain and multiply everything as fractions.

• The NTSC audio subcarrier over RF is defined as 9/2 MHz.
• The NTSC horizontal scan frequency* is defined as 1/286 of the audio subcarrier, or 9/572 MHz.
• The NTSC color subcarrier is defined as 455/2 times the horizontal scan frequency, or 315/88 MHz. This frequency is often called "color burst" or "3.58" after its rounded value.
• The exact value for the dot clock rate on NTSC and RGB PPUs is three-halves of color burst, or 945/176 MHz.
• The exact value for the CPU clock rate is one-third of the PPU dot clock, or one-half of color burst, or 315/176 MHz.

* This is the standard rate for 480i television. Prior to the Dreamcast, 480i was highly uncommon on video game consoles, and their picture generators applied various forms of cheating. Horizontal scan on NES and Super NES is slightly faster than this. Horizontal scan on many other 240p consoles is slightly slower. But it still works because it's within tolerances of actual TV sets.

Top

 Post subject: Re: CPU and PPU clock mathPosted: Sun Apr 26, 2015 8:46 pm

Joined: Sun Apr 05, 2015 7:16 am
Posts: 4
thefox wrote:
Also note that the real clock frequency is never exactly what is advertised, for example on the 21.47 MHz clock you can see a +-40 Hz tolerance in the page you linked.

If theres a +- 40Hz tolerance, then why is it important to care about being 1 PPU cycle short when its an odd frame. Wouldn't it not matter if the tolerance range is that big?

Top

 Post subject: Re: CPU and PPU clock mathPosted: Sun Apr 26, 2015 9:09 pm

Joined: Mon Apr 01, 2013 11:17 pm
Posts: 437
RobertLoggia wrote:
Wouldn't it not matter if the tolerance range is that big?
It would be fine if they used separate clock sources. For example, the SNES CPU and APU use different clock sources, which means the CPU and APU must communicate with each other periodically if they need to remain synchronized.

However, the NES CPU and PPU are both driven by the same crystal resonator. They are always exactly in sync. You could write code for the NES that synchronizes itself against the PPU once, and then runs forever without ever needing to synchronize itself again. I'm not aware of any games that specifically rely on the one-cycle odd/even difference, but there are a few that will break if your timing is too far off.

Top

 Post subject: Re: CPU and PPU clock mathPosted: Sun Apr 26, 2015 9:15 pm

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19783
Location: NE Indiana, USA (NTSC)
RobertLoggia wrote:
If theres a +- 40Hz tolerance, then why is it important to care about being 1 PPU cycle short when its an odd frame. Wouldn't it not matter if the tolerance range is that big?

To put it another way: There's a 40 Hz tolerance in the absolute rate of a particular clock source. There's no tolerance in the relative rate between two clocks derived from the same source.

Top

 Post subject: Re: CPU and PPU clock mathPosted: Tue Apr 28, 2015 10:51 pm

Joined: Sun May 27, 2012 8:43 pm
Posts: 1331
tepples wrote:
RobertLoggia wrote:
If theres a +- 40Hz tolerance, then why is it important to care about being 1 PPU cycle short when its an odd frame. Wouldn't it not matter if the tolerance range is that big?

To put it another way: There's a 40 Hz tolerance in the absolute rate of a particular clock source. There's no tolerance in the relative rate between two clocks derived from the same source.

To put it another another way: The minute difference in frequency will be proportionately reflected in all further divisions of the frequency. The PPU and CPU clock will maintain their clock ratio.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 7 posts ]

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: MLX and 10 guests

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

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki