📄 main.c
字号:
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
void main(void) {
DDRA=0x00;
REFDV=1;//3;
SYNR=4;//7;
while(CRGFLG_LOCK==0);
CLKSEL=0x80; //时钟初始化
PWME=0x12; //通道1使能
PWMPOL=0x12;//通道01输出波形开始极性为1
PWMCTL=0x10;//通道01级联
PWMCLK=0x12;//通道01选择SA为时钟源
PWMSCLA=0X04;//通道01时钟SA为3MHz(24/(2*4))
PWMPER01=60000;//设定通道01输出频率(50Hz)
PWMDTY01=3000;
PWMPER4=2000;
PWMDTY4=350;
while(1){
if(PORTA==0x08){
PWMDTY01=3000;
}
if(PORTA==0x04){
PWMDTY01=3300;
}
if(PORTA==0x10){
PWMDTY01=2700;
}
if(PORTA==0x02){
PWMDTY01=3700;
}
if(PORTA==0x20){
PWMDTY01=2300;
}
}
/* please make sure that you never leave this function */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -