/* TICK1190.C * * Example code for SBC1190 to set up 10ms timer routine */ /* The RUN.EXE firmware sets up timer 2 as a pre-scaler. Timer 2 divides the CPU clock down to 187.5kHz (for a 12MHz SBC1190), 312.5kHz (for a 20MHz SBC1190), or 390.625kHz (for a 25MHz SBC1190). This signal is then fed into timers 0 and 1. Timer 0 is used by RUN.EXE to further divide the signal down to a standard DOS 18.2Hz timer tick. Timer 1 is not used. This example for a 12MHz SBC1190 uses timer 1 to set up an interrupt service routine that is called every 10ms. NOTE: The timer 1 interrupt vector is determined by the 80C188EB processor and is fixed as being Int 12h. This interrupt is used by the RUN.EXE firmware to provide the PC-compatible memory-available routine. Any routines that require Int 12h to be PC-compatible (e.g. memory allocation), should be run before revectoring this interrupt */ void far interrupt timer_10ms_int(void); #ifndef __TURBOC__ #ifndef outport #define outport outpw #endif #ifndef inport #define inport inpw #endif #ifndef setvect #define setvect _dos_setvect #endif #endif #define EOI 0xFF02 #define T1CMPA 0xFF3A #define T1CON 0xFF3E #define I0CON 0xFF18 #define IMASK 0xFF08 unsigned int numticks; void setup_10ms_timer_interrupt(void) { /* setup timer 1 counter */ /* timer 0 is prescaler, output = 187.5kHz */ /* 187.5kHz/1875 = 100 Hz or approx 10 ms */ outport(T1CMPA, 1875); /* setup timer 1 interrupt vector */ /* Note that Int 12h may no longer be used to determine the memory available after this interrupt is revectored */ setvect(0x12, timer_10ms_int); /* setup timer 1 mode - continuous with int */ outport (T1CON, 0xE009); /* enable timer 1 int */ outport(IMASK, (inport(IMASK) & 0xFFFE)); } void far interrupt timer_10ms_int(void) { /* handle interrupt here */ numticks++; outport (EOI, 0x8000); /* EOI */ } void main(void) { setup_10ms_timer_interrupt(); }