Half-bridge PWM with a 16F684 ?


Results 1 to 8 of 8

Threaded View

  1. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Give this a shot;
    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    
    DEFINE OSC 8             '8MHz clock
    
    SYMBOL TMR2IF = PIR1.1 ' TMR1IF flag bit
    TRISA = %00000000   ' Set 'em all to outputs
    PORTC = 0 
    TRISC = %00110000   ' RC4 and RC5 left as inputs until ready 
    ANSEL = %00000000  ' Turn off that analog crap
    CMCON0 = 7
    OSCCON = %01110000 ' 8MHz internal
    
    PR2 = 101          ' load a value into PR2 for ~19.6kHz
    CCP1CON = %10001100 ' half bridge, all PWM outputs active high 
    CCPR1L = 50         ' set the PWM duty cycle ~50%
    PWM1CON = %10000011' set auto restart & deadband
    TMR2IF = 0
    T2CON = %00000100  'set prescaler to 1, prescaler to 1, timer 2 on
    
    WHILE TMR2IF = 0   ' wait for TMR2IF flag bit to set
    WEND
    TRISC = %11001111  ' now set RC4 & RC5 as outputs
    
    Main:
      GOTO Main
      
      END
    Attached Images Attached Images  
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  2. PWM setting PIC16F887
    By Gevo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th June 2008, 07:24
  3. Help with 16F684 PWM
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th November 2007, 02:20
  4. 18F4620 HPWM Half Bridge Mod problem
    By showtime in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd November 2007, 12:55
  5. Using HPWM in half bridge mode on 16f690
    By Chris Barron in forum mel PIC BASIC
    Replies: 0
    Last Post: - 29th December 2006, 11:18

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