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
PWM1 and 16F1827
Moderator: Benj
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PWM1 and 16F1827
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.
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.
- Attachments
-
- 16F1827.fcd
- (10.15 KiB) Downloaded 312 times
-
- 16F1826.fcd
- (10.15 KiB) Downloaded 305 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: PWM1 and 16F1827
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
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
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PWM1 and 16F1827
Hello Jan,
I think the 16F1825 device is ok but I will have a quick check and make sure for you.
I think the 16F1825 device is ok but I will have a quick check and make sure for you.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: PWM1 and 16F1827
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
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
-
- Flowcode V4 User
- Posts: 36
- Joined: Mon Sep 26, 2011 10:26 pm
- Has thanked: 9 times
- Been thanked: 2 times
Re: PWM1 and 16F1827
Benj
After updating of 16f1827.fcd my PWM stopped to work!
What happens?
Please advice
Thank you
After updating of 16f1827.fcd my PWM stopped to work!
What happens?

Please advice
Thank you
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PWM1 and 16F1827
Check you are not using the alternate pin in either the PWM properties or the chip config settings.After updating of 16f1827.fcd my PWM stopped to work!
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Flowcode V4 User
- Posts: 36
- Joined: Mon Sep 26, 2011 10:26 pm
- Has thanked: 9 times
- Been thanked: 2 times
Re: PWM1 and 16F1827
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
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
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PWM1 and 16F1827
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel