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

📄 pwmtimer.c

📁 avr的pwm测试代码
💻 C
字号:
//PWMTimer.c : source file for the PWM Timers
//

#include "PWM.h"
#include "PWMTimer.h"

/////////////////////////////////////////////////////////////////////////////
//PWMTimer

void timers_init(void)
{
	//{{WIZARD_MAP(Timers)
	// Timer/Counter0 Clock source: System Clock
	// Timer/Counter0 Clock value: 1000.000kHz
	// Timer/Counter0 Mode: Normal
	// Timer/Counter0 Output: A: Disconnected, B: Set
	OCR0A = 0x00;
	OCR0B = 0x00;
	TCNT0 = 0x00;
	TCCR0A = 0x00;
	TCCR0B = 0x02;

	// Timer/Counter1 Clock source: System Clock
	// Timer/Counter1 Clock value: 1000.000kHz
	// Timer/Counter1 Mode: PWM, Phase Correct, 8-bit
	// Timer/Counter1 Output: A: Disconnected, B: Disconnected
	OCR1A = 0x0000;
	OCR1B = 0x0000;
	TCNT1 = 0x0000;
	TCCR1A = 0x01;
	TCCR1B = 0x02;
	TCCR1C = 0x00;

	// Timer/Counter2 Clock source: System Clock
	// Timer/Counter2 Clock value: 1000.000kHz
	// Timer/Counter2 Mode: Normal
	// Timer/Counter2 Output: A: Disconnected, B: Disconnected
	ASSR = 0x00;
	OCR2A = 0x00;
	OCR2B = 0x00;
	TCNT2 = 0x00;
	TCCR2A = 0x00;
	TCCR2B = 0x02;

	TIMSK0 = 0x00;
	TIMSK1 = 0x06;
	TIMSK2 = 0x06;
	//}}WIZARD_MAP(Timers)
}

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

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

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

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

⌨️ 快捷键说明

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