CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Using Timer 3 & 4 to generate a PWM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
SB



Joined: 15 Jan 2004
Posts: 10

View user's profile Send private message

Using Timer 3 & 4 to generate a PWM
PostPosted: Thu Aug 17, 2006 9:46 am     Reply with quote

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

    Ttelmah
    Guest







    PostPosted: Thu Aug 17, 2006 10:08 am     Reply with quote

    setup_ccp5(CCP_PWM|CCP_USE_TIMER3);

    Best Wishes
    SB



    Joined: 15 Jan 2004
    Posts: 10

    View user's profile Send private message

    PostPosted: Thu Aug 17, 2006 10:13 am     Reply with quote

    Thank you, works perfectly now.
    Display posts from previous:   
    Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
    Page 1 of 1

     
    Jump to:  
    You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot vote in polls in this forum


    Powered by phpBB © 2001, 2005 phpBB Group