Information Technology Reference
In-Depth Information
Figure 10.4
Simple C program to test joystick button status
Thus, the timing values will change from 24.2 ms (for 0 kW) to 1.124 ms (for 100 kW). A sim-
ple program that determines the time it takes for AX to be set is given next:
2 Program 10.1
#include <stdio.h>
#include <conio.h>
int main(void)
{
unsigned int inval, start1, start2, start, end1, end2, end;
do
{
_outp(0x43,0); /* Specify Counter 0 */
start1=_inp(0x40); /* get LSB of Counter 0 */
start2=_inp(0x40); /* get MSB of Counter 0 */
_outp(0x201,0); /* start one-shot */
do
{
inval=_inp(0x201); /* read button status of joystick */
} while ((inval & 1)==1); /* wait till set to a 0 */
_outp(0x43,0); /* Specify Counter 0 */
end1=_inp(0x40); /* get LSB of Counter 0 */
end2=_inp(0x40); /* get MSB of Counter 0 */
Search WWH ::




Custom Search