PWM with 16F72


Closed Thread
Results 1 to 3 of 3

Thread: PWM with 16F72

  1. #1
    Join Date
    Jul 2008
    Posts
    5

    Default PWM with 16F72

    Hi All
    I am using 16F72 for a PWM application. I am using the hardware PWM module . I can see the PWM wave at the pin CCP1 and it is perfect. But when the CCP1 goes high i need to make RC0 and RC1 high and RC4 and RC5 low. And whenever CCP1 goes low , and i need to reverse these RC0 , RC1, RC4 and RC5.
    Now the CCP1 going high can be tracked using the TMR2IF flag. But how do i track when CCP1 goes low ? CCP1 goes low when there is a dutycycle match with the TMR2 , but i cannot find or think of any way to track that.
    I hope you all can help me in this.

    Thanks in advance
    Regards
    Sudip

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Sure about TMR2IF ?

    Hi,

    I do not understand the relation of TMR2IF being set with the CCP1 going high in the PWM Mode. Honestly speaking I am less experienced with the 16 series. However the PWM modules should work in the same way

    As far as I understand:
    TMR2IF is only set when TMR2 rollsover. In PWM that cannot happen if PR (period register is less than 255) or the duty cycle is less than 100%. Cause the PR match resets TMR2 -- CCP-PWM output = high, CCPR register match (concatenated with 2 bit internal Q clock of the prescaler) clears it.

    What you say is true when compare mode is used, not PWM mode.
    Correct me if I am wrong.

    Now coming to your problem.

    It seems you would be driving a half bridge using the PWM

    You can always use the compare mode to generate upto 16 bits of PWM and steer the outputs in the ISR as per your own requirement.

    Your nickname gives me a hunch that you are from Kolkata India and your full name is Sudip Mukherjee . If that is true then welcome to this great place which actually helped me gain confidence and little expertise in PIC.
    Last edited by sougata; - 29th July 2008 at 19:13.
    Regards

    Sougata

  3. #3
    Join Date
    Jul 2008
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Tmr2if

    Hi
    It seems you would be driving a half bridge using the PWM.
    I am using a full bridge and that is why i want four pins to control it. What i am doing is :- set the chip in PWM mode, made PR2 = 200 and CCPR1L is the duty cycle and also made TMR2IE=1. So whenever TMR2 matches CCPR register the CCP Pin goes low and then again when TMR2 mathes PR2 - 1) CCP pin goes high, 2) TMR2 rollsover, and 3) TMR2 interrupt is generated.
    You can always use the compare mode to generate upto 16 bits of PWM and steer the outputs in the ISR as per your own requirement.
    Anyway , can u please give me a litle idea about how to use the compare mode to generate PWM. I tried it initially , but whenever the duty cycle is getting small , it was not giving good result , so i thought of switching to PWM mode.

    You are absolutely right about my name and location . I am from south kolkata (hazra).

    Regards

    Sudip Mukherjee

Similar Threads

  1. Half-bridge PWM with a 16F684 ?
    By Byte_Butcher in forum General
    Replies: 7
    Last Post: - 17th January 2010, 22:18
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. PWM: Vernacular/Function (Newbee)
    By TerryN in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd July 2008, 16:58
  4. PWM setting PIC16F887
    By Gevo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th June 2008, 07:24
  5. Tidying Up PWM Routine
    By Tissy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st February 2005, 00:26

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts