Dual PWM's using 12F683? Failure, Suggestions?


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Dual PWM's using 12F683? Failure, Suggestions?

    OK I got it to work using a 12F1572. I wanted to post my code and see if anyone can spot something I need to clean up or rework. please note a small problem i ran into noted after code. DEFINE OSC 4 DEFINE ADC_BITS 8 ' A/D number of bits DEFINE ADC_CLOCK 1 ' Use A/D internal RC clock DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us 50 ADCON0.7 = 0 ' Justify Result to 10 & 8 bit Side RES1 Var byte ' A/D converter result RES0 VAR BYTE AGAIN: ADCIN 2, Res0 ' Read Channel 3 data ADCIN 3, Res1 ' Read Channel 3 data if res1 < 10 then res1 = 0 ' Low Auto Shutoff if res0 < 10 then res0 = 0 ' Low Auto Shutoff HPWM 2, res0, 10000 ' PWM Pin, Setting, Frequency (20k Max) HPWM 1, res1, 10000 ' PWM Pin, Setting, Frequency (20k Max) pause 5 goto again ----------------- sorry not in code block, my page doesnt show those options. ok the problem i ran into is that the 12f1572 is supposed to be capable of running up to 32mhz using internal clock I thought it read. however if i change the define to 32, then it slowwwws way down, also even when set to 4mhz i had to make my pause at the end 5, where it used to be 100 with older chips? any ideas on how i can specify a higher internal clock freq, and why i have to use such a low pause (if i use a 100 my leds flash, with a 5 they change fairly smoothly.)
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,656


    Did you find this post helpful? Yes | No

    Default Re: Dual PWM's using 12F683? Failure, Suggestions?

    Note that "DEFINE OSC" doesn't set or change the actual clock frequency. It only
    tells PBP what to expect. The actual frequency is set by selecting a crystal,
    changing the device configuration, setting registers in your program, or (most
    commonly) a combination of all of these.

    you need to set the OSCCON reg appropriately and the PLL config too to use the 32mhz clock

Similar Threads

  1. using the pwm's in pic18f2431-2331-4331-4431
    By jorge_jaqa in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 17th February 2018, 09:05
  2. Replies: 1
    Last Post: - 4th March 2013, 21:57
  3. PIC 16F690 PWM's ports selection - How to?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th September 2011, 20:08
  4. ADCIN failure
    By brid0030 in forum General
    Replies: 6
    Last Post: - 6th November 2007, 16:20
  5. Can you use 2 PWM's simultaneously?
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 30th June 2006, 18:50

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