?
Solved

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

Posted on 1998-04-18
4
Medium Priority
?
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

719 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