flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Timers

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 28 Nov 2007, 03:12
I am looking for info on programming a disk Timer or a timer in general..
info on iqr6..
no-bios
It would be for PMode

I been looking can't find much...

example:
start timer
stop timer
ect...

Thanks in advance!
Post 28 Nov 2007, 03:12
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 28 Nov 2007, 03:24
Image

Laughing

Jokes aside, though, go here:
http://www.osdever.net/bkerndev/index.php

and check the tutorial on the PIT.

It's pretty handy.
Post 28 Nov 2007, 03:24
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 28 Nov 2007, 03:30
lol! thanks!
Post 28 Nov 2007, 03:30
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 28 Nov 2007, 03:32
No problem! Very Happy Though I forgot that the timer IRQ went off every 18.222 seconds, though I knew it was constantly on (even from the start) because when I had it activated in my OS it would constantly display a message and not give room for anything else to operate. I have to re-write it before I enable it again. XD
Post 28 Nov 2007, 03:32
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 28 Nov 2007, 03:55
Quote:

hough I forgot that the timer IRQ went off every 18.222 seconds, though I knew it was constantly on (even from the start)

Maybe I'm misreading you but, wouldn't it be 18.222 interrupts per second rather than the timer turns off every 18.222 seconds?
Post 28 Nov 2007, 03:55
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 28 Nov 2007, 04:22
IIRC, there is a way to acknowledge the IRQ has been handled - resetting the delay counter. Otherwise, it fires off every chance it gets.
Post 28 Nov 2007, 04:22
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 28 Nov 2007, 05:02
LocoDelAssembly wrote:
Quote:

hough I forgot that the timer IRQ went off every 18.222 seconds, though I knew it was constantly on (even from the start)

Maybe I'm misreading you but, wouldn't it be 18.222 interrupts per second rather than the timer turns off every 18.222 seconds?


You're right. I apologize, though what you said is actually what I meant to type. Laughing
Post 28 Nov 2007, 05:02
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 28 Nov 2007, 05:20
Try this file - I can't remember where I got it from, but it's pretty good.

Although I would use 1193 instead of 1192 - this gives 1000.15 vs 1000.99


Description:
Download
Filename: fast_tmr.asm
Filesize: 3.46 KB
Downloaded: 380 Time(s)

Post 28 Nov 2007, 05:20
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 28 Nov 2007, 05:55
1000 int/second is too much
int spend time
push eflag, push eip, push cs
pop cs, pop eip, pop eflag

these 6 inherent instructions are repeat 1000 time/second.
it's too much

for my OS, i'm thinking about a 110Hz timer; cnt=10847,1
closer to 110 int/second, musical frequency 'LA'
or 24int/second for cinema FPS, cnt=49715,19{6}

or a real integral int/second, to see later.


PS: one strange thing, 1193182Hz is 1234DEh, note the 1234 string
amazing, no?
Post 28 Nov 2007, 05:55
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 28 Nov 2007, 06:07
That's the beauty of the code - just change "mov ax,1192" to your chosen divisor and you can go from 18.2 to 1,193,182(theoretically), but the comments say that a pentium 100(?) can run at 100,000 ticks/sec.

push,push,push/pop,pop,pop - this takes no time now (or at least very little) - it's all automatic.
Post 28 Nov 2007, 06:07
View user's profile Send private message Reply with quote
roboman



Joined: 03 Dec 2006
Posts: 122
Location: USA
roboman 28 Nov 2007, 07:20
http://www.powerbasic.com/files/pub/asm/8259.ZIP
is a good doc on the int chip on the pc. Also if you dig around in a lot of stepper motor control programs they use either the 8259 timer or the pent cpu built in timer
Post 28 Nov 2007, 07:20
View user's profile Send private message Visit poster's website Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 28 Nov 2007, 08:00
Thanks- I'll take a look!
Post 28 Nov 2007, 08:00
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 28 Nov 2007, 14:00
in case of cached stack, it is really fast. but takes at least 6 PUSH/POP, 6 cpu cycles.
but if the stack is in real ram, then you must wait RAM latency, it's a long time. more than 6 cpu cycle
ok , it's only 6 Push/pop, but in am, we shall code the fatest program as possible.
what about the 44100Hz audio sample rate? how to make this one stable?
is it integrated in the sound chip or the DMA controler?
Post 28 Nov 2007, 14:00
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 28 Nov 2007, 17:44
If in your clocktick IRQ it increaser's a counter every tick, from startup of your OS.
You just need function that gets count.
Example
Code:
mov ax,6 ;function numberint  40h  ; int 40 like dos in 21hmov dword[StartCount],ebx  ;returns tick so far in EBX;do what you want timed heremov ax,6 ;function numberint  40h  ; int 40 like dos in 21hsub ebx, dword[StartCount]  ;sub the start ticksmov dword[StopTime],ebx  ; save the ticks that have passed.    
Post 28 Nov 2007, 17:44
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 14 Dec 2007, 04:03
value for the nearest integral value of 100

1193182 / 14551 = 82Hz

good because integral, no decimal...
Post 14 Dec 2007, 04:03
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 14 Dec 2007, 04:51
edfed wrote:
value for the nearest integral value of 100

1193182 / 14551 = 82Hz

good because integral, no decimal...
That is only an illusion. The oscillator frequencies are only approximate. You should use something similar to Bresenham's algorithm to get closest to your desired frequency.
Post 14 Dec 2007, 04:51
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 14 Dec 2007, 05:21
erf Laughing
by googling besenham, just now, i discover that MY line algorithm is the besenham one... Sad
i didn't know that, it's not the besenham algorithm but the edfed one... Smile
i reinvent the weel everydays, and finally, i see that my weel is circular like all others Wink

what you speak about is not the besenham algorythm, it's a digital PLL, something that regulate the frequency... Idea
Post 14 Dec 2007, 05:21
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 14 Dec 2007, 06:46
edfed wrote:
what you speak about is not the besenham algorythm, it's a digital PLL
I meant what I said, Bresenham's algorithm. It is all a matter of perspective. I treat each interrupt as an x-increment and advance the timer whenever there is a y-increment needed. It gives maximal timing accuracy on a long term average and can be no more than off-by-one in the short term. It requires no floats or decimals, it is an all integer solution and is simple to program and understand.
Post 14 Dec 2007, 06:46
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 15 Dec 2007, 05:46
hum, by using this in timer, one very bad thing is the quantification error, because the time of periods is variable.


Description:
Filesize: 126.44 KB
Viewed: 9863 Time(s)

time.jpg


Post 15 Dec 2007, 05:46
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 15 Dec 2007, 06:54
edfed: You show an extreme case where the two frequencies are very close. Of course the difference will create what you see, it is called clock jitter. I already mentioned it will be 1 unit of difference maximum. So expect some severe jitter if the two frequencies are similar.

In any normal application, good programmers would to chose an interrupt frequency at least 10 times, and preferably >=20 times, the desired output frequency. That way the jitter is small enough to become imperceptible. Using ~1ms interrupt with 25 or 30 fps is a very good solution.
Post 15 Dec 2007, 06:54
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.