Using HPWM to blink an LED?


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425

    Default Using HPWM to blink an LED?

    Is there a way to use the HPWM to blink an LED? When I read the manual, it seems like you can only use high frequencies and the LED only appears to be bright or dim. I know you can connect external hardware, I guess like a shift register to do it but I'd rather just use the output of the PIC if possible.

    Thanks,

    Chris

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Christopher4187, There is no way to change the hardware divide string to make it any longer. You can only set the prescaler to it's maximum value of 16X and set the PR2 register for a maximum of 255. This will give you a minimum frequency of about 1.22 khz. at a 20 Mhz clock.

    Dave Purola,
    N8NTA

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Christopher,

    IF you'd wanted to use HPWM ... there's a Timer1 unused aboard your chip ... YESS !

    So, running TMR1 as a free timer and toggling the led at each TMR1 overflow interrupt ... will do the job. A basic interrupt should be enough ...

    Without any "external" counter, you should get a ~ 1 sec maximum period @ 4 Mhz clock ...

    Alain

    PS: It's a bit like giving marmelade to a pig ... but, if unused ...
    Last edited by Acetronics2; - 1st August 2006 at 12:49.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Yup TIMER interrupt is the way to go.
    Steve

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

  5. #5
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default

    I'm a bit confused about using the timer1. I have read Darrel's posts on his timers and trying to follow the code myself is very confusing. Is there a step by step explanation on how to do it. I didn't see anything in the manual and if there was I didn't see it.

    Thanks,

    Chris

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Chris,

    You've read this post?
    http://www.picbasic.co.uk/forum/showthread.php?p=23259

    What part don't you understand?

    How the Timer works?
    How the Interrupts work?
    How the program works?
    <br>
    DT

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Novice 16F83A BLINK LED program help
    By owali in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 25th July 2007, 05:02
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 14:14
  5. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43

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