I saved the original in another SAMPLES folder. Here is the first section of the PWM2 module that sets up the additional outputs then I added the PSTFCON = $07 in the main code which sets up the output steering which if I understand it correctly, two outputs are 180 degrees out of phase from the two other outputs. Pretty sure I have the register configuration wrong but experimenting. Wonder if I put the PSTFCON register setup in the PWM2 .bas module. The INCLUDES are setup first so before the code gets to the present register setting it would already be loaded. Am curious how to achieve the 180 degree output difference.
Code:
Module pwm
Dim
FMaxDuty As Word,
FTMR2ON As T2CON.2
#if _device in (18F1220, 18F1320)
Dim FPWM1Pin As PORTB.3 // RB3 connected to CCP1 module
#elseif _device in (18F13K22)
Dim FPWM1Pin As PORTC.5 // RC5 connected to CCP1 module
Dim FPWM2Pin As PORTC.4
Dim FPWM3Pin As PORTC.3
#else
Dim FPWM1Pin As PORTC.2 // RC2 connected to CCP1 module
Dim FPWM2Pin As PORTC.1 // RC1 connected to CCP2 module
#endif
{
****************************************************************************
* Name : Start1 *
* Purpose : Start PWM Channel 1 *
****************************************************************************
}
Public Sub Start1()
CCP1CON = $0c ' $0c PWM mode P1A, P1C active high :P1B, P1D active high
Output(FPWM1Pin)
Output(FPWM2Pin)
Output(FPWM3Pin)
FTMR2ON = 1
End Sub
{
Here is the PSTRCON register settings
REGISTER 13-4: PSTRCON: PULSE STEERING CONTROL REGISTER(1)
U-0 U-0 U-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-1
— — — STRSYNC STRD STRC STRB STRA
bit 7 bit 0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7-5 Unimplemented: Read as ‘0’
bit 4 STRSYNC: Steering Sync bit
1 = Output steering update occurs on next PWM period
0 = Output steering update occurs at the beginning of the instruction cycle boundary
bit 3 STRD: Steering Enable bit D
1 = P1D pin has the PWM waveform with polarity control from CCP1M<1:0>
0 = P1D pin is assigned to port pin
bit 2 STRC: Steering Enable bit C
1 = P1C pin has the PWM waveform with polarity control from CCP1M<1:0>
0 = P1C pin is assigned to port pin
bit 1 STRB: Steering Enable bit B
1 = P1B pin has the PWM waveform with polarity control from CCP1M<1:0>
0 = P1B pin is assigned to port pin
bit 0 STRA: Steering Enable bit A
1 = P1A pin has the PWM waveform with polarity control from CCP1M<1:0>
0 = P1A pin is assigned to port pin
Note 1: The PWM Steering mode is available only when the CCP1CON register bits CCP1M<3:2> = 11 and