// File : m11_pwm.c #include #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); }