...have attached a project file...
Pardon me for coming to the party late, but I was waiting for some code so that I could try to help you get to the bottom of things rather than try to guess. See Footnote.
I looked at your configuration and connected a 20 MHz external oscillator to CLKIN on pin 2. I connected a 'scope on PWM3OUT on pin 5.
I saw 100 KHz PWM starting at 100% duty cycle then sliding to zero where it stayed for "a little while," then started at max again. It went through this repeatedly.
I think that is reasonable, given your program. Maybe not what you had in mind, but the bottom line is that with proper clock input you should be able to see some output and, maybe, go from there to debug your code and maybe even get something useful from an application using PWM3.
Suggestion: For your own debugging of PWM3 and to give others a chance of helping, I would use internal clock. That way, you eliminate any possible external clock or clock connection problems, and people without an easy way to apply an external 20 MHz clock can be in a position to test and offer explicit help. Tested
with an external 3.3V power supply on my PIC16F15323 (DIP-14) solderless breadboard with an external 3.3V CMOS clock generator.
MPLABX version 5.35, XC8 version 2.10 (C99 mode), SNAP programmer.
I made no changes in any part of your code. The only project settings that I changed were to use my SNAP programmer rather than the PICkit3 that I think you used.
Footnote: My guess would have been some hardware problem. Either with the clock or with some other connection problem (bypass capacitors, reset connection, power, etc...) Personally I never waste a single New York minute on a project unless and until I can verify proper clock operation. It really makes no sense to try to debug PWM or anything else unless the clock is what I think it should be. (Toggle an LED in a loop with __delay_ms(1000) or some such thing.)
post edited by davekw7x - 2020/04/04 10:57:15