12F629 PWM usage


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    23

    Smile 12F629 PWM usage

    Hi, I have a question that involves how PBP runs in a 12F629 which is basically not knowing how the program runs. (guess I can't think at 4 mhz!!) I am fairly experienced at writing code so it assembles properly, but don't know how certain things run - if that's possible!!!
    When it does a goto a label, the first line in the label runs PWM (not HPWM) and outputs to a pin. There are additional lines in the label which do other things to a DIFFERENToutput.
    Question: Does PBP run the PWM first and WAIT until it is finished before moving on to the additional lines to do them, or does it start running the PWM, then move on to these other things BEFORE FINISHING THE PWM?
    Another way to put it is that I need to have these two things happening simultaneously on two separate outputs!
    Example: The first pin is outputting a percentage output WHILE the other is flashing on and off.

    PS I will put enough time in the PWM line to last until the other pin flashing is finished, then the code goes back, out of the label and will cancel everything. Also, the quality of the PWM is not important because it is driving an NPN which drives a mosfet, and only for about a minute - max. (the NPN makes it a pretty good square wave)
    Is there another command I could use instead of if/goto to insure that the label doesn't wait for the PWM to finish before moving on, such as a while/wend?
    Thanks for any help!
    Ron

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


    Did you find this post helpful? Yes | No

    Default

    PWM need to be finished before jumping to the next instruction. If you can deal with it, that great, unless you may need to use a Timer interrupt to produce your PWM or switch to the 12F683 which have a built-in PWM module.

    Multitasking will be more than likely time slicing process, but fast enough to looks like multitasking. Once again Timer interrupts are pretty handy.

    You can have a periodic timer interrupt and increase/decrease some variables in. Once you reach x value, then you enable/disable your i/os in the main program or in the ISR. But i usually prefer to do it in the mainloop when possible, keeping the ISR as short as possible.
    Steve

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

  3. #3
    Join Date
    Dec 2005
    Posts
    23


    Did you find this post helpful? Yes | No

    Wink Thanks Steve

    Thanks Steve. I never thought of timer interrupts. However, I need to use the 12F629 and will try to set up some multitasking in this and let you know if I get it going.
    Ron

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. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. PWM 'channels ...what's that all about then!
    By HankMcSpank in forum General
    Replies: 5
    Last Post: - 23rd April 2009, 16:49
  4. PWM setting PIC16F887
    By Gevo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th June 2008, 07:24
  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