下面是我的代码
- void PWM3_Initialize(void)
- {
- // Set the PWM to the options selected in the MPLAB® Code Configurator.
- // PWM3EN enabled; PWM3POL active_hi;
- PWM3CON = 0x80;
-
- // PWM3DCH 255;
- PWM3DCH = 0xFF;
-
- // PWM3DCL 192;
- PWM3DCL = 0xC0;
-
-
- // Select timer
- CCPTMRSbits.P3TSEL = 0x0;
- }
还有Timer2的设置
- void TMR2_Initialize(void)
- {
- // Set TMR2 to the options selected in the User Interface
- // TMR2ON off; T2CKPS 1:64; T2OUTPS 1:1;
- T2CON = 0x03;
- // PR2 255;
- PR2 = 0xFF;
- // TMR2 0x0;
- TMR2 = 0x00;
- // Clearing IF flag.
- PIR1bits.TMR2IF = 0;
- // Start TMR2
- TMR2_StartTimer();
- }
|