📄 m11_pwm.txt
字号:
// File : m11_pwm.c
#include <gc80c510_so20i.h>
#define PWM_DIVIDE_OSC 0
#define PWM_DIVIDE_OSC_2 1
#define PWM_DIVIDE_OSC_4 2
#define PWM_DIVIDE_OSC_8 3
#define PWM_DIVIDE_OSC_16 4
#define PWM_DIVIDE_OSC_32 5
#define PWM_DIVIDE_OSC_64 6
#define PWM_DIVIDE_OSC_128 7
void m11_pwm_clock(unsigned char divide)
{
PWMCON &= 0x8F;
PWMCON += (divide << 4);
}
void init_pwm()
{
//
// PWM PORT to P0.0
//
PWM0CON &= 0x7F;
ALTSEL |= 0x10;
//
// Set Pwm Clock
//
m11_pwm_clock(PWM_DIVIDE_OSC);
//
// Clear Counter
//
PWMCON |= 0x02;
//
// PWM Duty Setting
//
PWMD = 0x80;
//
// PWM Start
//
PWMCON |= 0x01;
}
void main()
{
init_pwm();
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -