Page 1 of 1

16F1827 PWM Channel 2 not working.

Posted: Wed Feb 02, 2011 1:37 pm
by medelec35
It does not matter if CCP2 is steered to RB6 or RA7, results still the same.
When CCP2 is steered to RB6 I can see a PWM with a duty of 5%.
Adjusting voltage on AN0, PWM1 varies as expected.
PWM2 stays at 5% or disappears altogether for the higher duty values.
Eb006 not able to program yet, used a different programmer.
Is there a quick fix please as this is an very important job, and under a lot of pressure to complete asap.
I have included a Very watered down flowchart for testing.
Using internal osc at 8MHz
Thank you.

Re: 16F1827 PWM Channel 2 not working.

Posted: Wed Feb 02, 2011 3:41 pm
by Benj
Hi Medelec,

Me and Sean have spent a bit of time on this now and so far we cannot see why the second PWM channel is misbehaving. I will carry on and see if I can resolve the problem for you, I'll post back on how I get on.

Re: 16F1827 PWM Channel 2 not working.

Posted: Wed Feb 02, 2011 4:00 pm
by Benj
Hi Medelec,

I dont think your going to like this.

I take it you are programming the chip from PICkit?

If you move the programming jumper from the ICD2 setting back to the USB setting then the PWM signal for CCP2 should then appear on the I/O port. When the jumper is in the ICD2 position the D-type port is disconnected for pins RB6 and RB7.

Could this be the problem? After moving the jumper back to USB here both PWM channels seem to be working fine on the code you supplied.

Re: 16F1827 PWM Channel 2 not working.

Posted: Wed Feb 02, 2011 4:14 pm
by medelec35
Benj wrote: If you move the programming jumper from the ICD2 setting back to the USB setting then the PWM signal for CCP2 should then appear on the I/O port. When the jumper is in the ICD2 position the D-type port is disconnected for pins RB6 and RB7.

Could this be the problem?
medelec35 wrote:It does not matter if CCP2 is steered to RB6 or RA7, results still the same
The chip is mounted on a separate PCB (Not using EB006 programmer at all for this one.), and just using ICSP to program chip. Programmer is then disconnected. Chip then runs via 5V regulator + decoupling caps. I can PM you the circuit if required.

No not using pickit. I am using ASIX presto.
With that arrangement if both channels work for you, could will be using different FCD or other files?
Would you mind posting a working hex file please so I can program chip with it and perhaps I can compare the two hex files?
Attached is my hex file

Re: 16F1827 PWM Channel 2 not working.

Posted: Wed Feb 02, 2011 4:50 pm
by Benj
Hi Medelec,

Yes here is the hex file I used. All it does is increment a variable every 5ms and output the variable to the CCP1 and CCP2, RB0 and RB6. When the count gets to 98 the variable is reset back to 0.
PWM_Duty_Test.hex
(1.04 KiB) Downloaded 366 times
I have also had a go with the hex file you sent and this also seems to be running fine on the EB006 hardware.

Re: 16F1827 PWM Channel 2 not working.

Posted: Wed Feb 02, 2011 5:00 pm
by Benj
Hello again,

Right I have just recompiled using the HiTech compiler instead of the BoostC one and i've hit the problem you are having. seems very odd that changing the compiler would have this much of an effect. I'll carry on and see where I get.

Testing again with the HiTech compiler I have got it all working. But I didnt change anything. Here is my FCF and Hex files that seem to be working correctly using the HiTech compiler.