Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Is is possible to generate timer interrupt in C?

Status
Not open for further replies.

thangaduraibeece

Junior Member level 2
Junior Member level 2
Joined
Jul 4, 2008
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,419
c timer interrupt

Hi,
I have a doubt in c that is ithere is possibilty to create a timer interrupt in C?
If it is possible,will it be possible to generate a interrupt for milliseconds time?
I know that we can have a software delay in terms of milliseconds using Delay(50ms) etc.But i think its not possible to use timer interrupt in C?
Any idea on this?
 

timer interrupt c

Yes, it is possible to write a timer interrupt in C.
Example: Microcontroller AVR ATmega 16, Compiler CodeVision


#include <mega16.h>

// Declare your global variables here

// Timer 0 output compare interrupt service routine
interrupt [TIM0_COMP] void timer0_comp_isr(void)
{
// Place your code here
}

void main(void)
{
// Declare your local variables here
...
...
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 7,200 kHz
// Mode: CTC top=OCR0
// OC0 output: Disconnected
TCCR0=0x0D;
TCNT0=0x00;
OCR0=0xEF;
...
...
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x02;

// Global enable interrupts
#asm("sei")

while (1)
{
// Place your code here
;
}
}
 

dos timer interrupt

Hi,
I think you are telling for the embedded c program for using timer interrupt.Sorry yaar, i want to use timer interrupt in C running on PC having windows OS if there is possibility...
 

timer interrupt in c

It is able with pure DOS but isn't possible with protected mode operating systems starting with NT 3.1 and Windows 95. The hardware resources, interrupts etc. are reserved to the kernel mode OS components. You have to write a kernel driver (Windows DDK is distributed by MS for shiping costs) to directly access a hardware resource. Alternatively special GiveIO drivers can cause the OS to grant direct hardware access, but it doesn't allow to install interrupt routines. Also third party tools as WinDriver are promising kernel-alike hardware access without learning DDK, but they are somewhat limited to my opinion.

By the way, Windows has advanced options as Multi-Media Timers accessible from
user mode (regular windows applications) that allow higher timer resolution.
 

timer interrupt

Hi,
If we can able to do it in DOS.Could you able to help in using timer interrupt?
I am ready to run this program in DOS.
Actually what my requirement is,
I need to do a tasks scheduling at the rate of 20 milliseconds and another in 50 ms.
In such a situation i need an interrupt to generate for every 10 milliseconds so that i can schedule some tasks and another interrupt to have 50 ms scheduling or i can use the same interrupt for base tmer and generate 50 milliseconds exactly.
 

windows timer interrupt

Using a 10 ms based scheduler for all tasks is favourable to my opinion. (Or better a 5 ms timer, if the DOS system timer, which is operating at 55 ms interval normally, is hooked and reprogrammed). You can serve the 55 ms systic and your tasks from a single timer.

Unfortunately I have no C code for you. I coded similar things 20 years ago with Borland Pascal.
 

timer interrupt dos

Hi,
Thanks yaar....If it is 55 milliseconds it is beneficial for me.I can use this as a base timer for my schedulings and also could you tell where can i get code for this?
 

time interrupt in c

Hi,
When i tied to run my program in pure DOS,COM Port is not opening.Could U have any solution for this?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top