代码如下,各位大虾给看看,用示波器测试PWM0口没有反映,到底怎么回事
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
#define PWCLK_ (*((volatile unsigned char*)(0x0040)))
#define PWPOL_ (*((volatile unsigned char*)(0x0041)))
#define PWEN_ (*((volatile unsigned char*)(0x0042)))
#define PWSCAL0_ (*((volatile unsigned char*)(0x0044)))
#define PWCNT0_ (*((volatile unsigned char*)(0x0048)))
#define PWPER0_ (*((volatile unsigned char*)(0x004c)))
#define PWDTY0_ (*((volatile unsigned char*)(0x0050)))
#define PWCTL_ (*((volatile unsigned char*)(0x0054)))
#define PORTP_ (*((volatile unsigned char*)(0x0056)))
void main(void) {
/* put your own code here */
EnableInterrupts;
PWCLK_ = 0x18; //通道分用A口32分频
PWPOL_ = 0x11; //用s0口做0通道的时钟 先高电平
PWSCAL0_ = 4; //s0口提供10kHz的频率
PWPER0_ = 99; //舵机的频率是100Hz
PWCNT0_ = 100;
DDRP = 0xff; //控制输出,此行有没有都结果
PWDTY0_ = 49;
PWEN_ = 0x01;
for(;;) {} /* wait forever */
}
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |