贴一个调试通过了的程序
#include /* common defines and macros */
#include /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
void main(void) {
/* put your own code here */
//EnableInterrupts;
PWME_PWME0 = 0x00;
PWMPRCLK = 0x04; //通道分用A口16分频
PWMCLK=0x01;//通道0用sA时钟源
PWMSCLA=75; //s0口提供10kHz的频率 24MHZ/16/2/75=10K
PWMPOL_PPOL = 1; //用s0口做0通道的时钟 先高电平
//对齐方式默认 左对齐
PWMPER0 = 200; //舵机的频率是50Hz 1/10k*x=1/50Hz
PWMDTY0 = 10; //占空比10%200
DDRP = 0xff; //控制输出
PWMCNT0 = 0;
PWME_PWME0 = 0x01;//PWM通道0输出
for(;;) {
} /* wait forever */
} |