HPWM - I need 10 bits


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1

    Default HPWM - I need 10 bits

    Hi,

    I have a problem with an 18F4620 project where the 8 bit PBP HPWM command is just too coarse. I really need 10 bit resolution to solve this.

    Does anyone have a code snip that shows how to drive the ECCP module for ten bit PWM resolution that they are prepared to share?

    Cheers
    Brian

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Look at pages 144-146 in the 18F4620 datasheet. It will tell you how to set up all the required registers. Specifically the section "15.4.4 SETUP FOR PWM OPERATION" tells you step by step exactly what to do.

    *edit* If after reading thru those pages you are still stuck, let me know what PWM frequency and duty cycle you are after and i'll help u out with some code.
    Last edited by Kamikaze47; - 26th September 2007 at 08:43.

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


    Did you find this post helpful? Yes | No

    Default

    PICMultiCalc will help to calculate the registers value, but yup, you still need to open the datasheet and make sure you place them at the right place.

    http://www.mister-e.org/pages/utilitiespag.html

    few example
    http://www.picbasic.co.uk/forum/show...ht=duty&page=2

    HTH
    Steve

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

  4. #4


    Did you find this post helpful? Yes | No

    Default Can we mix PBP and some direct register writes?

    Does anyone know if it is possible to set up HPWM in PBP then fine tune the values with a direct write to CCP1CON<5:4> which control the two LSB?

    This would let me stay with the PBP code I have and add a 'simple?' tweak where the 8 bit steps prove too coarse?

    Cheers
    Brian

  5. #5
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    You could try it, but I cant think of an easy way to test if it worked unless you have a scope handy to look at the output.

    Frankly, its not hard at all to set it up by directly writing to the registers. If anything it would be a good learning experience, as i'm sure this wont be the last time you will have to deal with registers like these.

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 14:14
  3. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43
  4. Need clever way to convert 10 bits to 8 bits
    By MikeTamu in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd September 2005, 15:13
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

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