View previous topic :: View next topic |
Author |
Message |
verba
Joined: 17 Aug 2004 Posts: 12
|
2 PWM in 16F876??? |
Posted: Tue Aug 17, 2004 12:16 am |
|
|
In the manual and in the datasheet, specifies that 16f876 has 2 PWM (C1 and C2).
I put this in the CCS:
Code: | setup_timer_2(T2_DIV_BY_1,9,1); //4Mhz, 100 Khz PWM timer
output_high(PIN_C1); //Init Pin C1 as output
output_high(PIN_C2); //Init Pin C2 as output
setup_ccp1(CCP_PWM); //Mode PWM CPP1
setup_ccp2(CCP_PWM); //Mode PWM CPP2
set_pwm1_duty(10); //Init PWM1 (10=100%..0=0%)
set_pwm2_duty(10); //Init PWM2 (10=100%..0=0%) |
Ok, this doesnīt work. Only works the PWM2 (C1) , the PWM1 (C2) is always 0.
Why? Whatīs is wrong? I canīt configurate the two PWM at same time?
Thank you very much |
|
|
Kenny
Joined: 07 Sep 2003 Posts: 173 Location: Australia
|
|
Posted: Tue Aug 17, 2004 1:31 am |
|
|
It works for me (compiler version 3.188). Your arithmetic is fine.
I didn't change anything in your code. Also I tested it by sweeping the values from 0 to 10 and back to 0, all OK. |
|
|
verba
Joined: 17 Aug 2004 Posts: 12
|
Not for me |
Posted: Tue Aug 17, 2004 3:34 am |
|
|
I have 3.155
Is it possible that my version doesnīt compile correctly the PWM ? |
|
|
|