Hello,

I'm struggling a little in finding how to assign either port P1A (PORTC.5) or P1B (PORTC.4) to output the PWM signal, one at the time (= not simultaneously) on a PIC16F690.

I drive a loudspeaker via a transistor and to modulate its volume, the transistor's base is connected to a 1k2 resistor on PORTC.5 and 15k resistor PORTC.4.

Reading the DS, I need to set registers CCP1CON.P1M<1:0> and CCP1CON.CCP1M<3:0> as well as, maybe, PSTRCON.STRA and PSTRCON.STRB.

Here's my code for testing. Unfortunately, it doesn't work

Anyone an idea if feasible? How?
Code:
@ __Config _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF &_PWRTE_OFF & _WDT_OFF & _INTOSC

Registers   76543210
OPTION_REG = %10000101 'PORT A&B Pull-Ups disabled (look WPUA & WPUB)
ANSEL      = %00000000 'Select analog inputs Channels 0 to 7
ANSELH     = %00000010 'Select analog inputs Channels 8 to 11
ADCON0     = %00000000 'A/D Module ON/OFF (Bit5:2 select channels 0:11)
ADCON1     = %00000000 'A/D control register
CM1CON0    = %00000000 'Comparator1 Module is OFF
CM2CON0    = %00000000 'Comparator2 Module is OFF
INTCON     = %00000000 'INTerrupts CONtrol (TMR0 ON)
TRISA      = %00000000 'Set Input/Output (0 to 5)
PORTA      = %00000000 'Ports High/Low (0 to 5)
TRISB      = %00000000 'Set Input/Output (4 to 7)
PORTB      = %00000000 'Ports High/Low (4 to 7)
TRISC      = %00000000 'Set Input/Output (0 to 7)
PORTC      = %00000000 'Ports High/Low (0 to 7)

' HPWM registers
T2CON      = %00000101 'Timer2 = ON (bit2), prescaler (bits1:0) 00=1, 01=4, 1x=16
CCP1CON    = %00001100 'Select PWM Mode
PR2        = 255       'frequency is around 1kHz

DutyCycle VAR WORD
DutyCycle = (PR2+1)*2
CCPR1L    = DutyCycle >> 2
CCP1CON.5 = DutyCycle.1
CCP1CON.4 = DutyCycle.0

'--------------------------------------
TEST:

PSTRCON.0 = 1 'PWM on PORTC.5
PAUSE 1000
PSTRCON.0 = 0

PSTRCON.1 = 1 'PWM on PORTC.4
PAUSE 1000
PSTRCON.1 = 0

GOTO TEST:
END