Solved

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

Posted on 1998-04-18
4
288 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 150 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

911 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

20 Experts available now in Live!

Get 1:1 Help Now