Hey guys,
I am on the process of developing a program in which i need to set the counter1 of the timer. As such, IRQ for timer is 0, but its common to all the 3 counters. Are there any ways in which we can set the counter1 specifically without affecting the functionality of the counter0???
How to set IRQ so as to initiate Counter 1???
Re: How to set IRQ so as to initiate Counter 1???
Hi,
I assume that on IRQ0, you are using the PIT and are referring to channels 0, 1 and 2. You are probably using channel 0 (not 1) on the PC architecture.
Channel 1 used to be used for RAM timing, but is now unneeded and is usually unconnected, so it can't be used for an interrupt, so you can forget about that.
Channel 2 is connected directly to the PC speaker, so you can forget that for causing interrupts on IRQ0 too - for now just concentrate on channel 0. When you initialise the PIT, you specify the channel number in the command register and there is a separate data register for each channel. For this reason, you shouldn't accidentally interfere with channels 1 and 2.
I suggest you have a look at the PIT article on the wiki.
Cheers,
Adam
I assume that on IRQ0, you are using the PIT and are referring to channels 0, 1 and 2. You are probably using channel 0 (not 1) on the PC architecture.
Channel 1 used to be used for RAM timing, but is now unneeded and is usually unconnected, so it can't be used for an interrupt, so you can forget about that.
Channel 2 is connected directly to the PC speaker, so you can forget that for causing interrupts on IRQ0 too - for now just concentrate on channel 0. When you initialise the PIT, you specify the channel number in the command register and there is a separate data register for each channel. For this reason, you shouldn't accidentally interfere with channels 1 and 2.
I suggest you have a look at the PIT article on the wiki.
Cheers,
Adam
Re: How to set IRQ so as to initiate Counter 1???
Code: Select all
void InitTimer()
{
OutP(0x43,0x34);
OutP(0x40,SYS_TIMER0_PERIOD);
OutP(0x40,SYS_TIMER0_PERIOD>>8);
}
void InitIrqs()
{
//Init 8259
OutP(0x20,0x11); //IW1
OutP(0xA0,0x11); //IW1
PortNop;
OutP(0x21,0x20); //IW2
OutP(0xA1,0x28); //IW2
PortNop;
OutP(0x21,0x04); //IW3
OutP(0xA1,0x02); //IW3
PortNop;
OutP(0x21,0x0D); //IW4
OutP(0xA1,0x09); //IW4
PortNop;
OutP(0x21,0xFA); //Mask all but IRQ0 (timer) and IRQ2 Cascade
OutP(0xA1,0xFF);
PortNop;
}
Here's the speaker code:
Code: Select all
if (freq) {
period=SYS_TIMER_FREQ/freq;
OutP(0x43,0xB6);
OutP(0x42,period);
OutP(0x42,period>>8);
OutP(0x61,3|InP(0x61));
} else
OutP(0x61,InP(0x61)&~3);
Re: How to set IRQ so as to initiate Counter 1???
Thanks a lot...
Re: How to set IRQ so as to initiate Counter 1???
Hi,
for my previous operation in 8254 timer chip, i was using Counter 0 (IRQ0)as a reference counter for a process where in the IRQ handler i was updating the count, but now i want to use counter 1 as the reference counter. As per your previous reply IRQ0 cannot be used for the counter 1. Please suggest any other ways (latching and reading the down counter etc.) to use the COUNTER 1 as reference.
for my previous operation in 8254 timer chip, i was using Counter 0 (IRQ0)as a reference counter for a process where in the IRQ handler i was updating the count, but now i want to use counter 1 as the reference counter. As per your previous reply IRQ0 cannot be used for the counter 1. Please suggest any other ways (latching and reading the down counter etc.) to use the COUNTER 1 as reference.
Re: How to set IRQ so as to initiate Counter 1???
I can think of a couple of ways. Firstly, have a global tick counter and use a getTickCount() function whenever you need the current value. If you take the tick count at the start and end of a code region, you can use the difference to find out how many ticks elapsed. This doesn't restrict the PIT to a single process.
Alternatively, you also have the RTC interrupt and the APIC timer. The APIC timers are generally suited quite well to scheduling because you have one timer per local APIC. This leaves the PIT free for whatever else you want.
Cheers,
Adam
Alternatively, you also have the RTC interrupt and the APIC timer. The APIC timers are generally suited quite well to scheduling because you have one timer per local APIC. This leaves the PIT free for whatever else you want.
Cheers,
Adam