fix Important bug in mikrobasic avr

Post your requests and ideas on the future development of mikroBasic PRO for AVR.
Post Reply
Author
Message
jet_media
Posts: 39
Joined: 18 Apr 2012 09:13
Location: Iran

fix Important bug in mikrobasic avr

#1 Post by jet_media » 05 May 2014 20:15

set Tools>Options>Output>Output Setting>optimization-->Zero

and test code ! :

program MyProject

main:

if 150 > 300 then
portc=255
else

end if
end.
'------------

Run "Portc=255" !!!!!!!
Attachments
BUG.zip
(55.81 KiB) Downloaded 143 times

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: fix Important bug in mikrobasic avr

#2 Post by petar.timotijevic » 05 May 2014 21:06

Hi,

You forgot to initialize and configure the port.

Try this code, code works ok:

Code: Select all

program MyProject

' Declarations section 

main:
'   Main program 
 
  DDRC  = 0xFF                                      ' configure PORTC as output
  PORTC = 0xAA                                      ' initial PORTC value you can delete this if you want

if 150 < 300 then
   portc = 0xFF
else
   portc = 0x1A
end if
end.
Best regards,
Peter

jet_media
Posts: 39
Joined: 18 Apr 2012 09:13
Location: Iran

Re: fix Important bug in mikrobasic avr

#3 Post by jet_media » 05 May 2014 23:26

petar.timotijevic wrote:Hi,

You forgot to initialize and configure the port.

Try this code, code works ok:

Code: Select all

program MyProject

' Declarations section 

main:
'   Main program 
 
  DDRC  = 0xFF                                      ' configure PORTC as output
  PORTC = 0xAA                                      ' initial PORTC value you can delete this if you want

if 150 < 300 then
   portc = 0xFF
else
   portc = 0x1A
end if
end.
Best regards,
Peter
Hi , Peter

in avr
When starting to work DDrX = 0 (all ports is Input)
and Portc = 255 ===> All PullUP resistors in Portc active

It does not matter!

A Question :
ex)
if 150 > 300 then
portc=255
else

end if

150 is smaller than 300
"Portc=255" command should not be executed

ex2)

program MyProject

dim c3 as char[3]
dim b as byte
main:
UART1_Init(19200)
b=0
if 150> 300 then
b=1
else

end if
ByteToStr(b,c3)
UART1_Write_Text(c3)
UART1_Write_Text("|")
end.
'---------------------------
150 is smaller than 300
"b=1" command should not be executed
But "B=1" command run!!!
and .... c3=1 !!!!

Please Test Attach File in Proteus software or ...
Attachments
BUG2.zip
(78.78 KiB) Downloaded 151 times

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: fix Important bug in mikrobasic avr

#4 Post by petar.timotijevic » 05 May 2014 23:49

Hi,

Please see screenshots in attachment.


Best regards,
Peter
Attachments
UartIf.gif
UartIf.gif (949.39 KiB) Viewed 3728 times
150L300.gif
150L300.gif (420.84 KiB) Viewed 3728 times

jet_media
Posts: 39
Joined: 18 Apr 2012 09:13
Location: Iran

Re: fix Important bug in mikrobasic avr

#5 Post by jet_media » 06 May 2014 07:57

petar.timotijevic wrote:Hi,

Please see screenshots in attachment.


Best regards,
Peter
Hi, Peter

Please see screenshots in attachment and test again.
Attachments
1.gif
1.gif (642.73 KiB) Viewed 3721 times

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: fix Important bug in mikrobasic avr

#6 Post by marina.petrovic » 06 May 2014 14:18

Hi,

I tested the simple examples that you posted and I didn't manage to reproduce the same behavior in my compiler,
like my colleague Petar already mentioned.

Please, try to update your compiler (Help -> Check for Updates).
Last version of mikroBasic PRO for AVR is v6.0.1.

Best regards,
Marina

Post Reply

Return to “mikroBasic PRO for AVR Wish List”