I've got HWPWM 1 (RC2/CCP1) feeding into TMR1 counter input (RC0/T1CKI).
I want the PWM set at 1KHz @ 50%...
I've programmed the PIC (16F877A I/P) and it's running but TMR1 is not incrementing... A standard Digital multimeter reports a solid 5 volts on RC2/CCP1...
When i simulate the software in oshonsoft PIC simulator i set up an simulated signal generator to RC0/T1CKI tmr1 input and i can see TMR1L and TMR1H registers increment... However, HWPWM1 goes high and stays high... I've left it running for an hour on my PC (>65,000uS simulation time)...
The following code is used to initialise my PIC...
Code:
Define CONF_WORD = $3F3A
include "bs1defs.bas"
Define OSC 24 ' Set clock speed
DEFINE SER2_BITS 8 ' Ser2 number of data bits
SEROUT2 PORTB.5,16390,[10,13,10,13]
SEROUT2 PORTB.5,16390,["INITIALISING",10,13]
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_SAMPLEUS 100 ' Set sampling time in uS
ADCON0.6 = 1 ' ADC clock set to Fosc/64
ADCON0.7 = 1 ' ADC clock set to Fosc/64
ADCON1.6 = 0 ' ADC clock set to Fosc/64
INTCON = 0 ' Disable all interupts
'RCSTA = %10010000 ' Enable serial port and continuous receive
'TXSTA = %00100100 ' Enable transmit and asynchronous mode with BRGH 1
'SPBRG = 20 ' Set baud rate to 57600 with 20mhz clock (BRGH = 1)
###A load of variables go here###
TRISE = %00000111 ' Set PortE to all inputs
TRISD = %00000000 ' Set PortD to all outputs
TRISC = %00000001 ' Set PortC to all outputs
TRISB = %00000000 ' Set PortB to all outputs
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = 0 ' PORTA is analog
PORTB = 0
PORTC = 0
PORTD = 0
gosub TMR1setup
HPWM 1,127,1000
SEROUT2 PORTB.5,16390,["INITIALISED",10,13]
TMR1setup:
TMR1L = 0 ' reset TMR1 low to 0
TMR1H = 0 ' reset TMR1 high to 0
PIE1.0 = 0 ' Disable TMR1 interupt (double check)
T1CON.5 = 0 ' Setup TMR1 timings 1:1
T1CON.4 = 0 ' Setup TMR1 timings 1:1
T1CON.3 = 1 ' Oscillator is on
T1CON.2 = 1 ' Do not synchronize external clock input
T1CON.1 = 1 ' External clock from pin RC0
T1CON.0 = 1 ' Enables Timer1
return
so the HW PWM is set with and i've checked the syntax.
Can anyone see whats wrong?
Thanks
Bookmarks