⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 float1.c

📁 美国tern公司开发的嵌入式开发平台586E
💻 C
字号:
/*
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -