SB
Joined: 15 Jan 2004 Posts: 10
|
Using Timer 3 & 4 to generate a PWM |
Posted: Thu Aug 17, 2006 9:46 am |
|
|
I'm using a Microchip PIC18F8722 development board and want to generate 2 PWM signals at different frequencies.
I don't have any problem with using Timer 2 but am unable to get Timer 3 to work.
Below is my attempt to get timer 3 to generating a signal on PWM5.
I am using PCH V3.234
Does anyone know what I am doing wrong?
Thanks
Code: | setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED|T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_INTERNAL|T3_DIV_BY_1|T3_CCP1_TO_5);
setup_timer_4(T4_DIV_BY_1,19,1);
setup_ccp5(CCP_PWM);
set_pwm5_duty((long int)40);
|
.................... setup_timer_3(T3_INTERNAL|T3_DIV_BY_1|T3_CCP1_TO_5);
011E: MOVF FB1,W
0120: ANDLW 48
0122: IORLW CD
0124: MOVWF FB1
.................... setup_timer_4(T4_DIV_BY_1,19,1);
0126: MOVLW 00
0128: IORLW 04
012A: MOVWF F76
012C: MOVLW 13
012E: MOVWF F77
.................... setup_ccp5(CCP_PWM);
0130: MOVLW B7
0132: ANDWF FB1,F
0134: BCF F98.4
0136: BCF F8F.4
0138: MOVLW 0C
013A: MOVWF F70
.................... set_pwm5_duty((long int)40);
013C: MOVLW 0A
013E: MOVWF F71
0140: MOVF F70,W
0142: ANDLW CF
0144: MOVWF F70
|
|