Solved

Precise interval timer using MFC and VC++ - can anyone help?

Posted on 1998-04-18
4
286 Views
Last Modified: 2008-03-03
I have written a program using Borland's Turbo C++ 3.0 for DOS which is reading
data from hardware port 300h in 1ms intervalls. To do this I had to redirect the
timer interrupt #08h to a self written subroutine. Because the PC's timer intervall
is set to some strange 18ms by default I also had to reprogram the timer chip (8253)
to get the desired 1ms. This program works well but since it is a DOS
program using only pure C code the user interface is very limited. I don't
want to spent weeks only for programming a nice UI when I can do this
in hours using MFC. So I tried to port it to MS VC++. But the compilation
ends up with a "function returns function" error message for the
declaration of the function which installs the new interrupt service routine.
This is the logic of the program:

void InstallTimer(void interrupt (*intrserv)(), int freq_Hz);     /*  <-- this line leads to VC++ syntax error */
.
.
void interrupt IntrServerRoutine(void)  /* here I define the interrupt service routine */
{
   /* does the timer dependent IO stuff */
}
.
.
InstallTimer(IntrServRoutine, 1000/*Hz*/);   /* here I reprogram the 8253 chip and install interrupt service routine */


Why does this work with Turbo C but not with MS VC++? Does
anyone know how to implement this with VC++?  I can give
the Turbo C source code to anyone who thinks he/she is
able to help me or just to anyone who's interested in it.
0
Comment
Question by:rernst
  • 2
4 Comments
 
LVL 22

Expert Comment

by:nietod
Comment Utility
What is the "interrupt" word defined as?  It is not a keyword, at least not in MSVC++.
0
 
LVL 3

Accepted Solution

by:
altena earned 150 total points
Comment Utility
You have a long way to go rernst...

The only way (as far as i can see...) is to write a device
driver. Only then will you have direct access to the hardware
under windows 95 / NT. (windows 95 is a little more forgiving,
but under NT applications are not supposed to go to the hardware at all.

Off course your next question is: How do i write a device driver?
One way is to get the windows DDK. for exampl by going to
MSDN online (www.microsoft.com/msdn) when you sign up an an
online member (free) you get access to the full MSDN-library
which includes the DDK. (and some samples).

By the way, this is not going to be a trivial excersise. You probably need to rework a lot of your code.

good luck.
0
 

Author Comment

by:rernst
Comment Utility
Dear nietod,

thank you for stating it so clearly! I should have known better that there's no way
to avoid writing a device driver. I will get me the DDK and try to learn how to
program a DD. Maybe I can find a way to modify an existing DD.
BTW, you are right, "interrupt" is not a keyword in VC++.

Thanks a lot.

0
 

Author Comment

by:rernst
Comment Utility
oops! I am sorry, altena!!!

By mistake I adressed nietod instead of you when I wanted to grade your answer.

Thank you again for your response!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now