测频extint.c

来自「基于AVR平台」· C语言 代码 · 共 38 行

C
38
字号
//测频ExtINT.c : source file for the 测频 External Interrupts
//

#include "测频.h"
#include "测频ExtINT.h"

/////////////////////////////////////////////////////////////////////////////
//测频ExtINT
extern uint number_int0_new;
extern uchar fb;
void extint_init(void)
{
	//{{WIZARD_MAP(External IRQ)
	// INT0 Enabled, Mode: Rising Edge
	MCUCR |= 0x03;//1 1:INT0上的上升沿产生中断请求
	MCUCSR |= 0x00;
	GICR = 0x40;//Bit 6 – INT0: 使能外部中断请求 0
	//}}WIZARD_MAP(External IRQ)
}

SIGNAL(SIG_INTERRUPT0)
{
	// TODO: Add your code here
	extern uint round_f;
	static uint odd_dat;
	number_int0_new=TCNT1;
	if (number_int0_new >= odd_dat)
	{
	  round_f=(number_int0_new-odd_dat);
	}
	 else
	 {
	 	round_f=(0xffff + number_int0_new - odd_dat);
 	 }
	odd_dat=number_int0_new;
	fb=0;
}

⌨️ 快捷键说明

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