FREQOUT - PWM question


Results 1 to 8 of 8

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Yes the internal CCP module set in PWM will handle it for you AND in background.

    Depending you OSC speed you'll have more or less DutyCycle resolution. But anyway, you want it 50% right?

    Unfortunately due to it's limitations, PBP HPWM won't help. You'll need to calculate and write the right value to the PIC registers.

    To do ALL related calcs, i will suggest to use my PicMultiCalc available bellow
    http://www.mister-e.org/pages/utilitiespag.html

    Once you have it, it's piece of cake.

    Here's something working @4MHZ
    Code:
            '
            '       38KHz PWM @ 4MHZ using a PIC16F877
            '       ----------------------------------
            @  __CONFIG _XT_OSC & _LVP_OFF
            '
            '
            TRISC = 0
            Duty        var byte
            
            '
            '       PWM SETUP
            '       =========
                    ' PicMultiCalc says..
                    '   Duty value for 50%=52
                    '   PR2 = 25
                    '   PRESCALLER 1:1
                    '   
                    '
            duty = 52                           ' duty value for 50% duty cycle
            PR2 = 25                            '
            T2CON = %00000100                   ' timer2 on, prescale 1:1
            CCPR1L = duty>>2                    ' MSB of duty cycle value
            CCP1CON=%00001100 | (dUTY<<5)       ' set PWM mode and store the 
                                                '   2 LSB of duty        
    SpinInRound:
            goto spininround
    also have a look to those...
    http://rentron.com/PicBasic/IR_Chips.htm
    http://rentron.com/IR_TO_RF.htm
    http://rentron.com/Infrared_Communication.htm
    Last edited by mister_e; - 25th February 2007 at 22:49.
    Steve

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

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. Pull Up enabled and PWM question
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th September 2009, 08:21
  3. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  4. Hardware PWM Question?
    By jhorsburgh in forum General
    Replies: 1
    Last Post: - 18th August 2008, 03:07
  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 : 0

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