- UID
- 806031
|
本帖最后由 yumuzi 于 2010-2-3 10:45 编辑
刚接触这款单片机 想写个简单的PWM 但怎么都不出波形,希望大家帮我看看问题在哪里?先谢谢了。- #include <hidef.h> /* common defines and macros */
- #include <mc9s12c32.h> /* derivative information */
- #define Pwm_Cycle 100
- #pragma LINK_INFO DERIVATIVE "mc9s12c32"
- void pwm1_init();
- void main(void) {
- /* put your own code here */
- DDRP=0xff;
- pwm1_init();
- EnableInterrupts;
- // DisableInterrupts;
- for(;;) {} /* wait forever */
- }
- //=================================
- void pwm1_init()
- {
- PWME =0x00; // pwm disable
- PWMPOL =0x02; //正极
- PWMCLK =0x02; //1通道 SA
- PWMPRCLK = 0x07; //clock A =bus clock /128
- PWMCAE = 0x00; //left align
- PWMCTL =0x00; //separate
- PWMSCLA =0x01; //clock sa=clock a/2
- PWMPER1 =99;
- PWMDTY1 =60;
- PWME =0xFF; //pwm1 enable
- }
复制代码 |
|