Solved

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

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

Independent Software Vendors: 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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

733 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