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

📄 cepintimer.c

📁 基于AVR平台
💻 C
字号:
//cepinTimer.c : source file for the cepin Timers
//

#include "cepin.h"
#include "cepinTimer.h"

/////////////////////////////////////////////////////////////////////////////
//cepinTimer

void timers_init(void)
{
	//{{WIZARD_MAP(Timers)
	// Timer/Counter0 Clock source: System Clock
	// Timer/Counter0 Clock value: Stopped
	// Timer/Counter0 Mode: Normal
	// Timer/Counter0 Output: Disconnected
	OCR0 = 0x00;
	TCNT0 = 0x00;
	TCCR0 = 0x00;

	// Timer/Counter1 Clock source: System Clock
	// Timer/Counter1 Clock value: 8000.000kHz
	// Timer/Counter1 Mode: Normal
	// Timer/Counter1 Output: A: Disconnected, B: Disconnected
	OCR1A = 0x0000;
	OCR1B = 0x0000;
	TCNT1 = 0x0000;
	TCCR1A = 0x00;
	TCCR1B = 0x42;//上升沿捕捉,8分频

	// Timer/Counter2 Clock source: System Clock
	// Timer/Counter2 Clock value: Stopped
	// Timer/Counter2 Mode: Normal
	// Timer/Counter2 Output: Disconnected
	ASSR = 0x00;
	OCR2 = 0x00;
	TCNT2 = 0x00;
	TCCR2 = 0x00;

	TIMSK = 0x65;
	//}}WIZARD_MAP(Timers)
}

SIGNAL(SIG_INPUT_CAPTURE1)
{
	uint f1,f2;
	extern uint f3;
	// TODO: Add your code here
	f1=ICR1;
	if(f1 >= f2)
		f3=f1-f2;
	else
		f3=0xffff-f2+f1;
	f2=f1;
}

SIGNAL(SIG_OUTPUT_COMPARE2)
{
	// TODO: Add your code here
	
}

SIGNAL(SIG_OVERFLOW1)
{
	// TODO: Add your code here
	TCNT1=0x0000;
}

⌨️ 快捷键说明

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