6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 3:34 am

All times are UTC




Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: 65C02GPD v2
PostPosted: Sun Jan 17, 2016 10:56 am 
Offline

Joined: Mon Aug 05, 2013 10:43 pm
Posts: 258
Location: Southampton, UK
cbscpe wrote:
Even if the actual frequency of the interrupt is 128Hz and not 100Hz it still can be used, you just need to take that into account, or am I wrong on this?


Sure. It's only a issue of you want to record the passege of time as a whole number of seconds and milliseconds, or whatever. But you could use seconds and 128ths of a second, it's just less convenient, especially if you want to display it.

_________________
8 bit fun and games: https://www.aslak.net/


Top
 Profile  
Reply with quote  
 Post subject: Re: 65C02GPD v2
PostPosted: Sun Jan 17, 2016 12:49 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
You can get a decent approximation of a second and centisecond (1/100th of a second) counter using the following method:
  1. take a single byte counter, and add 200 to that counter every 128 Hz timer tick
  2. when the counter overflows (carry=1), add 1 to the centisecond counter.
  3. when the centisecond counter reaches 100, reset it to 0, and increment second counter.
Fairly simple to implement in 6502 assembly.


Top
 Profile  
Reply with quote  
 Post subject: Re: 65C02GPD v2
PostPosted: Sun Jan 17, 2016 1:09 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
That's clever! Isn't it in fact exact? You're counting in units of 200/256 which is exactly 100/128.


Top
 Profile  
Reply with quote  
 Post subject: Re: 65C02GPD v2
PostPosted: Sun Jan 17, 2016 1:25 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
The second counter is exact, but the centisecond counter has a bit of jitter.


Top
 Profile  
Reply with quote  
 Post subject: Re: 65C02GPD v2
PostPosted: Sun Jan 17, 2016 1:32 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Ah, right - frequency is spot on, but phase wanders a bit.


Top
 Profile  
Reply with quote  
 Post subject: Re: 65C02GPD v2
PostPosted: Sun Jan 17, 2016 1:39 pm 
Offline

Joined: Mon Aug 05, 2013 10:43 pm
Posts: 258
Location: Southampton, UK
After 2 ticks, 2 * 1/128 seconds will have passed, but only 1/100 of a second will have been counted. It's still very very clever.

_________________
8 bit fun and games: https://www.aslak.net/


Top
 Profile  
Reply with quote  
 Post subject: Re: 65C02GPD v2
PostPosted: Sun Jan 17, 2016 4:09 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8514
Location: Midwestern USA
cbscpe wrote:
Even if the actual frequency of the interrupt is 128Hz and not 100Hz it still can be used, you just need to take that into account, or am I wrong on this?

If you are using a counter that is incremented or decremented with each jiffy you simply start at $00 or $80 and go from there. In the former case, when it hits $80 or in the latter case, when it hits $00, you'd reset the jiffy count and bump the seconds.

As long as the jiffy count has no special meaning to anything other than the routine that maintains the time, I don't see any reason why an odd interrupt rate would be a handicap. That said, the POC's BIOS returns the instantaneous jiffy count when the GESUTIM (get system uptime) function is called, which gives the uptime a 10 millisecond resolution. For that reason, use of a time base that increments exactly at 10 millisecond intervals is necessary if the return count is to be accurate. That's where the counter/timer in the 28L92 comes in.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 26 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: