PWM

所属分类:单片机开发
开发工具:C/C++
文件大小:5KB
下载次数:33
上传日期:2012-12-20 17:42:51
上 传 者chenxyong
说明:  Atmega 16单片机,这里利用T/C1定时器中断来产生PWM波形。在ICC AVR编译环境下,利用tool 菜单中的application builder生成一个简单的PWM波程序。这段程序以PA0作为PWM波的输出端口。利用T/C1定时器比较匹配和溢出产生两次中断来改变PA0的输出电平。具体过程为:计数器TCNT1从初始值开始不断计数,当发生比较匹配时,把PA0置为低电平,计数器继续计数,当发生溢出中断时,计数器回到初始设定值,并把PA0置为高电平。从而在PA0端口获得一稳定持续的PWM波形,在主程序中改变比较值,即可改变波形占空比,而频率不变。
(Atmega 16 microcontroller, T/C1 timer interrupt to generate a PWM waveform. ICC AVR compiler environment, the application builder tool menu to generate a simple PWM wave program. This program PA0 as PWM wave output ports. The use of T/C1 timer compare match and overflow twice interrupted PA0 to change the output level. Process: the counter TCNT1 from the initial value began to count, compare match occurs, the PA0 set low, the counter continues to count when an overflow interrupt occurs, the counter back to the initial setting, and PA0 is set to the high level. PA0 port access to a stable and sustainable PWM waveform, change the comparison value in the main program, you can change the waveform duty cycle, and the frequency is the same.)

文件列表:
PWM (25600, 2012-12-20)

近期下载者

相关文件


收藏者