That's the code, well... it's just THE part of the cooking-timer code to make that "half-bridge" PWM work:
Code:
'-------------------------------------------------------------------------------
' PIC 16F690 Fuses (MPASM)
@ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_HS_OSC &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
'-------------------------------------------------------------------------------
' Registers 76543210
OPTION_REG = %10000110 ' Pull-Ups OFF, Prescaler TMR0 1:128
ANSEL = %00000000 ' Select analog inputs Channels 0 to 7
ANSELH = %00000001 ' Select analog inputs Channels 8 to 11
WPUA = %00000000 ' Select weak pull-ups
WPUB = %00000000 ' Select weak pull-ups
ADCON0 = %10000000 ' AD Module
ADCON1 = %00000000 ' AD control register
CM1CON0 = %00000000 ' Comparator1 Module
CM2CON0 = %00000000 ' Comparator2 Module
INTCON = %10100000 ' INTerrupts CONtrol; GIE=1, T0IE=1
TRISA = %00000000 ' Select Input/Output (0 to 5)
PORTA = %00000000 ' Set High/Low (0 to 5)
TRISB = %00110000 ' Select Input/Output (4 to 7)
PORTB = %00000000 ' Set High/Low (4 to 7)
TRISC = %01000000 ' Select Input/Output (0 to 7)
PORTC = %00000000 ' Set High/Low (0 to 7)
' HPWM registers
T2CON = %00000101 ' Timer2 = ON (bit2), prescaler (bits1:0) 00=1, 01=4, 1x=16
CCP1CON = %10001100 ' Select PWM Mode (%00001100 = PWM module ON)
CCPR1L = 62 ' Dutycycle set to 50% (= percentage of PR2)
PR2 = 124 ' Freq 4kHz
Bookmarks