Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 1998-04-18
4
Medium Priority
?
308 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
ID: 1161942
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 450 total points
ID: 1161943
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
ID: 1161944
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
ID: 1161945
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
Suggested Courses

971 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