PWM1 and 16F1827
Posted: Fri Oct 28, 2011 1:18 pm
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
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