Page 1 of 1

PWM1 and 16F1827

Posted: Fri Oct 28, 2011 1:18 pm
by Jan Lichtenbelt
The microcontroller 16F1827 has the possibility of 4 PWM's. Flowcode can use the first two. PWM2 works correctly, but PWM1 fails when used with Flowcode. This is due to the fact that the wrong output port is programmed. The default output port for PWM1 is B3 and for PWM2 is B6. In the assembler program it can be seen that B0 instead of B3 is used.
This problem can easily be overcome in Flowcode by puting zero on B3 as output directly after enabling PWM1 (setting trisb to the correct value).

Succes

Jan Lichtenbelt
---------------
; { FCD_PWM0_Enable ; function begin
MOVLW 0xFF
MOVWF gbl_pr2
MOVLW 0x06
MOVWF gbl_t2con
DECF FCD_PWM0_E_00047_arg_nIdx, W
BTFSS STATUS,Z
GOTO label4
MOVLW 0x0C
MOVLB 0x05
MOVWF gbl_ccp1con
MOVLB 0x01
BCF gbl_trisb,0
label4
MOVLB 0x00
MOVF FCD_PWM0_E_00047_arg_nIdx, W
XORLW 0x02
BTFSS STATUS,Z
RETURN
MOVLW 0x0C
MOVLB 0x05
MOVWF gbl_ccp2con
MOVLB 0x01
BCF gbl_trisb,6
RETURN
; } FCD_PWM0_Enable function end

Re: PWM1 and 16F1827

Posted: Fri Oct 28, 2011 2:26 pm
by Benj
Hello Jan,

Thanks for the info. Here are a couple of fixed FCD files that should resolve the problem for you.

Also all PWM channels have been added to the v5 FCD file so hopefully we should be able to support all PWM channels rather then just 2.

Re: PWM1 and 16F1827

Posted: Mon Oct 31, 2011 4:49 pm
by Jan Lichtenbelt
Dear Ben,

At the end, I will use the smallest PIC as possible. The equivalent 14 pins is the 16F1825. Is there also an update of the FDC file for this microcontroller?

Kind regards

Jan

Re: PWM1 and 16F1827

Posted: Mon Oct 31, 2011 5:53 pm
by Benj
Hello Jan,

I think the 16F1825 device is ok but I will have a quick check and make sure for you.

Re: PWM1 and 16F1827

Posted: Tue Nov 15, 2011 2:41 pm
by Jan Lichtenbelt
Dear Ben,

Please be informed that the TRM1 with transition on T1CKI pin does not work correctly with 16F1825.
st_bit(t1con,TMR1CS); gives an error (TMR1CS unknow identifier).

TMR1CS<1:0> is bit<7:6> of T1CON register and should become 10 in this mode.

I do not use it now, but a suggestion is to improve the FCD file for the Flowcode V5.

Kind regards

Jan Lichtenbelt

Re: PWM1 and 16F1827

Posted: Wed Nov 16, 2011 12:26 pm
by Dmitry Maximenko
Benj
After updating of 16f1827.fcd my PWM stopped to work!
What happens? :-)
Please advice
Thank you

Re: PWM1 and 16F1827

Posted: Wed Nov 16, 2011 3:56 pm
by Benj
After updating of 16f1827.fcd my PWM stopped to work!
Check you are not using the alternate pin in either the PWM properties or the chip config settings.

Re: PWM1 and 16F1827

Posted: Wed Nov 16, 2011 8:54 pm
by Dmitry Maximenko
Hi Benj!
When I had old FCD file it worked when I had option "alternate pin" activated, not without it.
OK,now, when I changed to new FCD it seems to work if I change "alternate pin" to off.
Should it work that way?

Benj, what do you mean by "or the chip config settings"?

Thank you!
Best Regards
Dmitry

Re: PWM1 and 16F1827

Posted: Fri Nov 18, 2011 5:54 pm
by Benj
Hello,

To use the alternate PWM pin you have to enable the setting in the PWM properties window and enable the setting in the Chip -> Configure -> Expert Settings window.