float1.c

来自「美国tern公司开发的嵌入式开发平台586E」· C语言 代码 · 共 54 行

C
54
字号
/*
Courtesy of: nokamil@yahoo.com, submitted 3/6/2003.
All rights reserved, no warranties offered.

This program can be used to calculate the time of any event in 586 engine
Note that clock is 33.333Mhz/4 = 8.3325MHz therfore one clock pulse = inverse of it ie. .12Usec.
Therefore 49998pulses = 6msec. So interrupt will generate after every 6 msec.
*/


#include <dos.h>						/* signal(), raise() prototypes */
#include	<setjmp.h>						/* setjmp(), longjmp() prototypes */
#include	<math.h>							/* Trig, exponential function prototypes */
#include	<float.h>						/* Low-level floating point definitions */
#include	<string.h>
#include	"586.h"		 				// 586E initialization
#define ERR_LIMIT 0.000001
#define MMCR 0xdf00
unsigned int t0,ta,tb,tmStart,tmStop,ledd,t1,t2;
float actualTime = 0.0;
void interrupt far t0_isr (void);

void main(void){
	sc_init();//586 initialization
   tmStart = 0xe001;	//	start count word
	tmStop = 0x8000;	//	stop count word

   //Start Timer
	ta=(unsigned int)49998;// equivalent to 6 msecAs one clock=1/8.3325 = .120012 microsec
	tb=(unsigned int)49998;
   t0=0;
	t0_init(tmStart,ta,tb,t0_isr);
   t1=t0_rd();

   //Here you can paste your code, here i insert delay() function
   delay_ms(100);

   //Stop the timer
   t2=t0_rd();
	t0_init(tmStop,ta,tb,t0_isr);
   actualTime = (t2-t1)*.00012 + t0*6;

   while(1);
}


void interrupt far t0_isr (void){
	t0++;
   pokeb(MMCR,_GPTMRSTA_,0x01|peekb(MMCR,_GPTMRSTA_)); // Clear T0 status
// Issue the EOI to interrupt controller
	outportb(_S2PICOCW2_IO,0x60);	// Specific EOI for slave 2 IR0
  	outportb(_MPICOCW2_IO,0x65); // Specific EQI for master IR5
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?