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

📄 pwm.c

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

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

/////////////////////////////////////////////////////////////////////////////
//PWM

static void io_init(void)
{
	//{{WIZARD_MAP(General)
	//}}WIZARD_MAP(General)

	//{{WIZARD_MAP(I/O Ports)
	// PortB
	PORTB = 0x0;
	DDRB = 0x0;
	// PortC
	PORTC = 0x0;
	DDRC = 0x0;
	// PortD
	PORTD = 0x0;
	DDRD = 0x0;
	//}}WIZARD_MAP(I/O Ports)

	//{{WIZARD_MAP(Watchdog)
	// Watchdog Enabled, Prescaler: OSC/16k
	wdt_enable(WDTO_15MS);
	//}}WIZARD_MAP(Watchdog)

	//{{WIZARD_MAP(Analog Comparator)
	// Analog Comparator Disabled
	ACSR = 0x80;
	//}}WIZARD_MAP(Analog Comparator)
}

static void reset_checking(void)
{
	if (MCUCSR & BV(PORF))
	{	// Power-on Reset
		
	}
	else if (MCUCSR & BV(EXTRF))
	{	// External Reset
		
	}
	else if (MCUCSR & BV(WDRF))
	{	// Watchdog Reset
		
	}
	MCUCSR &= 0xE0;
}

int main(void)
{
	// Reset source checking
	reset_checking();
	//{{WIZARD_MAP(Initialization)
	io_init();
	adc_init();
	timers_init();
	//}}WIZARD_MAP(Initialization)
	// TODO: Add extra initialization here
	
	//{{WIZARD_MAP(Global interrupt)
	sei();
	//}}WIZARD_MAP(Global interrupt)
	while(1)
	{
		// TODO: Add your code here
		
	}
}

⌨️ 快捷键说明

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