?? time0.c
字號:
/********************************************************************************/
//
// builder : 2007-04-10
// Target : ATMEAG 48V
// Crystal : 內部 8.00 MHz
//
// PWM 模塊
/********************************************************************************/
#include <avr/io.h>
#include <avr/delay.h>
#include <avr/signal.h>
#include <avr/interrupt.h>
#define uchar unsigned char
#define uint unsigned int
//TIMER0 initialize - prescale:8
// desired value: 1Hz
// actual value: Out of range
void timer0_init(void) // PWM
{
TCCR0B = 0x00; //stop
TCNT0 = 0x01; //set count
TCCR0A = 0x23;
OCR0A = 0xff;
}
/*---------------------------------------------------------------
PWM 占空比設置
----------------------------------------------------------------*/
void Pwm_set(uchar pwm)
{
OCR0B = pwm;
if(TCCR0B == 0)
{
TCCR0A = 0x23;//0x23;
TCCR0B = 0x01; //start timer
}
}
/************************** the end ********************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -