MB 5.0.0.3 beta4 : Strange GLCD behaviour

Discuss about beta versions of mikroBasic
compiler.
Post Reply
Author
Message
Kalain
Posts: 1093
Joined: 11 Mar 2005 18:26
Location: Aubenas, France

MB 5.0.0.3 beta4 : Strange GLCD behaviour

#1 Post by Kalain » 02 Sep 2007 14:35

Hi,

Try this code (18F452) :

Code: Select all

program Test_Glcd

symbol item_menu = 5

Const menu1 as string[item_menu][10] = ("AAAAAAAA","BBBBBBBB","CCCCCCCC","DDDDDDDD","EEEEEEEE")

dim
  text1 as string[10]
  i     as  byte

main:
  TRISA = $FF
  TRISB = 0
  TRISD = 0
  ADCON1 = 7
  ADCON0 = 0
  
  PORTA = 0

  Glcd_Init(PORTB, 2, 3, 4, 5, 7, 6, PORTD)
  Glcd_Fill(0x00)
  Glcd_Set_Font(@FontSystem5x8, 5, 8, 32)

  i= 0
  do
    Text1 = menu1[i]
    Glcd_Write_Text(Text1,0,i+2,1)
    inc(i)
  loop until i = 2

  i=0
  Text1 = menu1[i]
  Glcd_Write_Text(Text1,0,i+2,1)

end.
In debugger mode, instructions inside loop are well executed and simulated.
Now after the loop, there is exactly the same instructions but behaves differently than the first loop instruction in Text1 = menu1 (i = 0)

Text1 is loaded and simulated with jerk string. It was ok inside the loop.

Well, I hesistate a while to publish this topic here rather than MB forum. (thinking hardly this is a bug and not a code problem. :?: )
Alain

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#2 Post by yo2lio » 02 Sep 2007 15:41

Hello,

Bad NEWS, problem is in OPTIMIZER !!!!!!! :?

Code: Select all

  ...
  ...
  i=0
  Text1 = menu1[i] 'Compiler see menu1[i] as global variable , not a constant .... !!!!!!!
  Glcd_Write_Text(Text1,0,i+2,1)
Try this code :

Code: Select all

program Test_Glcd

symbol item_menu = 5

Const menu1 as string[item_menu][10] = ("AAAAAAAA","BBBBBBBB","CCCCCCCC","DDDDDDDD","EEEEEEEE")

dim
  text1 as string[10]
  i     as  byte

main:
  TRISA = $FF
  TRISB = 0
  TRISD = 0
  ADCON1 = 7
  ADCON0 = 0
 
  PORTA = 0

  Glcd_Init(PORTB, 2, 3, 4, 5, 7, 6, PORTD)
  Glcd_Fill(0x00)
  Glcd_Set_Font(@FontSystem5x8, 5, 8, 32)

  i= 0
  do
    Text1 = menu1[i]
    Glcd_Write_Text(Text1,0,i+2,1)
    inc(i)
  loop until i = 2

  i=0
  asm nop end asm ' STOP OPTIMIZER HERE !!!!!!!!
  Text1 = menu1[i] 
  Glcd_Write_Text(Text1,0,i+2,1)

end. 
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Kalain
Posts: 1093
Joined: 11 Mar 2005 18:26
Location: Aubenas, France

#3 Post by Kalain » 02 Sep 2007 17:10

yo2lio wrote:Hello,

Bad NEWS, problem is in OPTIMIZER !!!!!!! :?

Code: Select all

  ...
  ...
  i=0
  Text1 = menu1[i] 'Compiler see menu1[i] as global variable , not a constant .... !!!!!!!
  Glcd_Write_Text(Text1,0,i+2,1)
Strangely, this instruction is correctly simulated (or executed) when it's inside DO LOOP!
Try this code :

Code: Select all

....
  i=0
  asm nop end asm ' STOP OPTIMIZER HERE !!!!!!!!
  Text1 = menu1[i] 
  Glcd_Write_Text(Text1,0,i+2,1)

end. 
With "asm nop end asm" it works perfectly ! :lol:

Hmm, I often feel deeply humble in front of so high people PIC knowledge......

Thanks
Alain

Post Reply

Return to “mikroBasic Beta testing”