ATMage16的16位定时器的PWM应用
// Target : M16
// Crystal: 8.0000Mhz
//TIMER1 initialize - prescale:64
// WGM: 10) PWM phz correct, TOP= ICRn
// desired value: 1Hz
// actual value: 1.000Hz (0.0%)
#include
#include
#define PWM1A
#define PWM1B
unsigned char OCAH;
unsigned char OCAL;
unsigned char OCBH;
unsigned char OCBL;
void timer1_init(void)
{
TCCR1B = 0x00;
TCNT1H = 0x00;
TCNT1L = 0x01;
OCR1AH = OCAH;
OCR1AL = OCAL;
OCR1BH = OCBH;
OCR1BL = OCBL;
ICR1H = 0xff;
ICR1L = 0xFF;
TCCR1A = 0xA3;
TCCR1B = 0x0B;
}
void init_devices(unsigned char valueah,unsigned char valueal,unsigned char valuebh,unsigned char valuebl)
{
OCAH=valueah;
OCAL=valueal;
OCBH=valuebh;
OCBL=valuebl;
CLI();
timer1_init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x04;
SEI();
}
void main(void)
{
PORTD&=(0
while(1);
}
[Copy to clipboard]
我爱avr,我爱虚拟仪器。
ATMage1616位定时器PWM应 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)