quick question


Closed Thread
Results 1 to 3 of 3

Thread: quick question

  1. #1
    Join Date
    Jul 2004
    Location
    CA
    Posts
    78

    Default quick question

    I konw that the On-Board PWM can be performed in the background, and that when you are not using the PWM module the duty cycle freeezes until you come back to it in code. Here is what I need to konw.. Where does the CCPx registers get stored adn how can I retrive the data for the duty cycle for the PWM mode. Basically what I am asking is lets say I am using the ON-Board CCP1 (PWM MODE) and I freeze it in the main loop. Now in a different subroutine I want to continue this, How can I do that. I have tried many options but with not success.

    here is what I have tried:
    I have saved the value of the duty variable before jumping out of the main loop .. now in the subroutine I set the duty = SAVED value of the duty cycle before I jumped out. I get that the CCP value is full ON. How do i fix this problem?

    any help on this topic would be greatly appreciated. thanks

    srigopal

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    hi srig,
    can you post the code you have try with the PIC you are using?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The PWM period is specified by writing to the PR2 register. PWM frequency is defined as 1 / [PWM period].

    The PWM duty cycle is specified by writing to the CCPR1L register and to the CCP1CON bits 5 & 4.

    Whatever values you place in these registers stays there until you put something else there or a hardware reset clears everything back to the power-up defaults.

    CCP1CON = 12 turns on PWM
    CCP1CON = 0 turns it off

    All you need to do is write to CCP1CON to turn hardware PWM on/off. It's going to come back on at the same frequency & duty cycle you had it setup for originally, and stay there until you write different values to the control registers or a hardware reset.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Quick DS18B20 question
    By gti_uk in forum General
    Replies: 4
    Last Post: - 21st June 2009, 17:24
  2. Quick USB CRC5 question
    By Michael Wakileh in forum USB
    Replies: 2
    Last Post: - 12th June 2009, 04:23
  3. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 06:49
  4. PIC16F84A - Quick question
    By samuelbarber in forum mel PIC BASIC
    Replies: 1
    Last Post: - 29th June 2005, 14:32
  5. Interrupt Quick Question
    By shawn in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th January 2005, 05:51

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