I had pwm working fine with my LabX1 and PIC 16F887. In my circuit, the 16F88 does not work. I have a scope on the output and I see nothing. Here's relevant code: (I took out some code to do with other operations to make it easier to read). By the time the program hits the HPWM command, I should see wigglies on the scope. I see nothing. I started ONLY with that command (and TRISB) and added the other config fuses and defines later in attempt to make it work. BTW, the other part of the program (timer, interrupts, A/D for voltage measurement) WORKS, so I know the MCU and oscillator and stuff is okay. I want to use RB3 (CCP1). I've reduced frequency to 8000 Hz for testing.
Any ideas?
#config
__config _CONFIG1, _LVP_OFF & _CP_OFF &_MCLR_ON & _PWRTE_OFF & _WDT_OFF & _CCP1_RB3 & _INTRC_IO & _CCPMX_RB3
#endconfig
duty var byte
freq var word
'Initialize
OSCCON= %01110000 'Internal oscillator, 8 MHz
TRISA= %11111111 'Set PORTA <D7-D0> to input
TrisB= %00000000 'set portb <D7-D0> to output
ANSEL= %00000011 'set portA analog on PortA <0-1>
ADCON0= %01001111 'enable ADC channel 0 and 1
ADCON1= %10000000 'right justify result
temp=0 'variable for Button command
Pause 100 'Wait for LCD to start up
define ccp1_reg PortB
define ccp1_bit 1
duty=127 '50% duty cycle
freq=8000 'test frequency
hpwm 1,duty,freq 'Start PWM 38000 khz signal from RB3 of 16F88
Bookmarks