Plz check the code and confirm the bug,
I found that in PWM2_Stop() procedure the compiler does not check config bit "CONFIG3H.CCP2MX" and it only assume that CCP2 is RC1 but in PIC18F4550 wh have 2 CCP2 pins. (RC1 and RB3)
You can see the PWM2_Stop() procedure in .lst file that I attacked and here:
Code: Select all
_PWM2_Stop:
;__Lib_PWM_c21.mpas,75 ::
;__Lib_PWM_c21.mpas,76 ::
0x02EC 0x8294 BSF TRISC1_bit, BitPos(TRISC1_bit+0)
;__Lib_PWM_c21.mpas,77 ::
0x02EE 0x0EF0 MOVLW 240
0x02F0 0x16BA ANDWF CCP2CON, 1
;__Lib_PWM_c21.mpas,78 ::
L_end_PWM2_Stop:
0x02F2 0x0012 RETURN 0
This is because PWM2_Stop() procedure try to set RC1 to input ( or something) but as you can see RC1 is configured for LCD RS and this is the result after that:
Code: Select all
program InferaRED
dim LCD_RS as sbit at RC1_bit
LCD_EN as sbit at RC0_bit
LCD_D4 as sbit at RD0_bit
LCD_D5 as sbit at RD1_bit
LCD_D6 as sbit at RD2_bit
LCD_D7 as sbit at RD3_bit
LCD_RS_Direction as sbit at TRISC1_bit
LCD_EN_Direction as sbit at TRISC0_bit
LCD_D4_Direction as sbit at TRISD0_bit
LCD_D5_Direction as sbit at TRISD1_bit
LCD_D6_Direction as sbit at TRISD2_bit
LCD_D7_Direction as sbit at TRISD3_bit
main:
Lcd_Init()
Lcd_Cmd(_LCD_CLEAR)
PWM2_Init(40000)
PWM2_Set_Duty(127)
lop:
lcd_out(1,1,"test")
PWM2_Start()
delay_ms(1)
'ccp2con = ccp2con and 240 put this code insted of next line to fix the bug
PWM2_Stop()
goto lop
end.
Regards
Arvin