Infrared HPWM setup


Results 1 to 20 of 20

Threaded View

  1. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,666


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Infrared HPWM setup

    why have we shifted?
    CPRxL value is the upper 8 bits of the duty cycle word valueCCP1CON bit 4 and 5 are the lower two bits



    (011010010) 210>>2 = 00110100 = 52 ;high 8bits
    (011010010) 210 & 3 = 00000010 = 2 ;low 2 bits

    00000010<<4 = 00100000
    CCP1CON = 00100000 |12 to set low bits in pwmmode

    C version from microchip
    Code:
    void PWM1_LoadDutyValue(uint16_t dutyValue)
    {
       // Writing to 8 MSBs of pwm duty cycle in CCPRL register
        CCPR1L = ((dutyValue & 0x03FC)>>2);
        
       // Writing to 2 LSBs of pwm duty cycle in CCPCON register
        CCP1CON = ((uint8_t)(CCP1CON & 0xCF) | ((dutyValue & 0x0003)<<4));
    }
    Last edited by richard; - 1st June 2023 at 08:07.
    Warning I'm not a teacher

Similar Threads

  1. Replies: 3
    Last Post: - 23rd October 2011, 12:53
  2. InfraRed Data Com
    By rayzrocket in forum Off Topic
    Replies: 5
    Last Post: - 29th March 2010, 15:42
  3. Infrared x PIC
    By ewandeur in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th December 2009, 18:30
  4. infrared help
    By griffin in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th December 2008, 05:34
  5. infrared
    By bmohnsen in forum General
    Replies: 1
    Last Post: - 2nd May 2007, 16:35

Members who have read this thread : 4

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