Here's an example for the 12F615.
This has a 1uS dead-band with roughly 12kHz PWM, and each output is the compliment ofCode:@ DEVICE PIC12F615, MCLR_OFF, IOSCFS_4MHZ, INTRC_OSC_NOCLKOUT, WDT_OFF, BOD_OFF, PROTECT_OFF DEFINE OSC 4 duty VAR WORD ANSEL = 0 ' 12F615 Set all pins to digital CMCON0 = 0 OPTION_REG = 0 ' Disable internal pullups WPU = 0 ' 12F615 Individual pull-ups disabled VRCON = 0 ' Internal Vref disabled TRISIO = %00111010 ' GPIO.0 = P1B, GPIO.2=P1A outputs PR2 = 82 ' Set PWM for approximately 12kHz CCP1CON = %10001100 ' PWM mode; P1A active-high; P1B active-high T2CON = %00000100 ' %00000110 = TMR2 ON 1:16 prescale PWM1CON = %10000001 ' min dead-band time Duty = 166 ' Roughly 50% duty cycle CCP1CON.4 = duty.0 CCP1CON.5 = duty.1 CCPR1L = DUTY >> 2 MAIN: GOTO MAIN End
the other.




Bookmarks