manual hardware PWM setup on 16F1824


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Here is the location for Steve's Multi-Calc. It is quite helpful.

    http://www.picbasic.co.uk/forum/cont....-PICMultiCalc

    If you wanted 8 bit PWM using the hardware, you could shift your 8 bits to change it to 10, matching the hardware.

    something like this:
    Code:
    DUTY1 var word
     
    DUTY1 = 255                    'put in some 8 bit value
    DUTY1 = DUTY1 <<2          'shift your 8 bits to 10 bits
    CCP1CON.5=DUTY1.1       ' load CCP1 duty value            
     CCP1CON.4=DUTY1.0       '      with Duty1 
    CCPR1L=DUTY1>>2
    Last edited by ScaleRobotics; - 29th January 2011 at 01:53.

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Not a perfect solution

    This is not a perfect solution, but you could just leave the 2 LSB's set to 0, then just use 8 bits for the MSB's. This will allow you to set PWm to zero, but not 100%
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3


    Did you find this post helpful? Yes | No

    Default

    or... i could just times the 8 bit duty by 4...

    but still, why does the datasheet, even the one for the 18F4550 'indicates' a variable bit resolution...

    TABLE 24-5: EXAMPLE PWM FREQUENCIES AND RESOLUTIONS (FOSC = 32 MHz)
    Code:
    PWM Frequency                1.95 kHz 7.81 kHz 31.25 kHz 125 kHz 250 kHz 333.3 kHz
    Timer Prescale (1, 4, 16)   16          4           1              1          1           1
    PRx Value                         0xFF      0xFF       0xFF         0x3F     0x1F      0x17
    Maximum Resolution (bits) 10         10           10            8          7           6.6
    Thats a copy of the table from the datasheet... as best i can get it over
    So, saying their is maximum resolution that is less than what the physical hardware can do indicates that you can change the resolution...

    So, where do you change it?
    HOW do you then only use 8 bits as indicated?
    I've now read through 3 'guides' but they have not told me what i need to know...
    However...
    One of them indicated that PR was the period register used for setting the time lenght for each cycle...
    However this can't possibly be true since that would mean the chip was built back to front... It would be more logical to set the frequency and then set the number of bits....

    ???????

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