PWM using the 12F683


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Apr 2016
    Location
    Plainfield, Illinois
    Posts
    73


    Did you find this post helpful? Yes | No

    Default Re: PWM using the 12F683

    So is this command needed If I'm using any output pin? Does setting the OSC mode to 8Mhz do anything for the PWM as far as resolution or is 4Mhz good enough? (I'm dimming LEDs).

    CCP1CON = %00001100 ' CCP1, PWM mode

    and

    OSCCON = %01110001 ' Internal 8MHz osc.
    DEFINE OSC 8
    My dad never liked you...

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


    Did you find this post helpful? Yes | No

    Default Re: PWM using the 12F683

    easy way

    Code:
    ;pic12f683
    #CONFIG
    cfg = _INTOSCIO
    cfg&= _WDT_ON
    cfg&= _PWRTE_OFF
    cfg&= _MCLRE_ON
    cfg&= _CP_OFF
    cfg&= _CPD_OFF
    cfg&= _BOD_ON
    cfg&= _IESO_ON
    cfg&= _FCMEN_ON
      __CONFIG cfg
    #ENDCONFIG
    
    
    DEFINE OSC  8
    OSCCON=$70
    CMCON0    = 7
    TRISIO   = %111011      ;gp2= output
    
    ANSEL    =0
    ; hpwm Channel, Dutycycle, Frequency
      
    hpwm     1,128,600   ;       50% 600 hz
     
    mainloop:
    
    ; do stuff
    
    goto mainloop
    
    
    


    to do it manually

    Code:
     TRISIO   = %111011      ;gp2= output
        t2con=5       ; set up timer/pr2  for frequency and pwm  bits   ; note this is not equivalent to above  resulting freq is ? [you work it out]
        PR2 = 255;
        CCPR1L = pulswidth     ; set pulsewidth high bits
        ccp1con=12             ; set ccp reg and or pulsewidth  low bits











































































    Last edited by richard; - 25th April 2016 at 05:57.

Similar Threads

  1. 12F683 2 x PWM Outputs
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 23rd July 2021, 20:20
  2. Dual PWM's using 12F683? Failure, Suggestions?
    By wdmagic in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 17th October 2015, 01:22
  3. please help with 12f683 pwm code
    By haidar in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 22nd May 2013, 21:25
  4. 12f683 comparator and pwm
    By Automan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd May 2007, 18:05
  5. PIC 12f683 AD/PWM Problems:
    By surfer0815 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th December 2005, 16:48

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