I found a bug in Microbasic v7.6.0 Compiler on CCP2

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
arvinfx
Posts: 115
Joined: 22 Feb 2010 18:44

I found a bug in Microbasic v7.6.0 Compiler on CCP2

#1 Post by arvinfx » 17 May 2020 07:50

Dear , Development team

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
When I call PWM2_Stop() in my code in Lcd i see all fulled by test string!!!
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:


lcd.jpg
lcd.jpg (58.95 KiB) Viewed 796 times


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.
I found a solution for it, Just put "ccp2con = ccp2con and 240" insted of PWM2_stop() solved my problem , But i think you can fix it in next release.

Regards
Arvin
Attachments
InferaRED.rar
(23.15 KiB) Downloaded 63 times

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: I found a bug in Microbasic v7.6.0 Compiler on CCP2

#2 Post by filip.grujcic » 19 May 2020 08:06

Hi Arvin,

Thank you for reporting this to us. I will forward it to our development team.

Kind regards,
Filip Grujcic

Post Reply

Return to “mikroBasic PRO for PIC General”