Menu

Bug in AVR LCD Handler?

joe rocci
2011-10-29
2013-05-30
  • joe rocci

    joe rocci - 2011-10-29

    I have an Arduino Uno board with an AT328P AVR processor. I also have an Arduino LCD display shield. I can successfully write to the LCD from the Arduino compiler environment.

    Next, wrote this simple program in GCBasic to write to the same Arduino/LCD hardware:

    'LCD connection settings
    #define LCD_IO 4
    #define LCD_NO_RW
    #define LCD_DB4 PORTD.4
    #define LCD_DB5 PORTD.5
    #define LCD_DB6 PORTD.6
    #define LCD_DB7 PORTD.7         
    #define LCD_RS PORTB.0
    #define LCD_Enable PORTB.1

    dim test as byte
    test= 0
    PRINT test

    When the value of the "test" variable is changed, the LCD output is irrational:
    "test"    LCD
    0           0
    1           1
    2           2
    3           blank
    4           4
    5           blank
    6           6
    7           blank
    8           8
    9           9 

    Attempting to write any character string literal of any length just displays that number of blank graphic blocks .

    Am I doing something wrong, or is this a bug in the AVR LCD handler?

    Joe     

     
  • joe rocci

    joe rocci - 2011-10-29

    Please ignore my previous. I think I might have an assembler compatibility issue (Using Gerd's AVR Assembler for this experiment). I'll post again when I have an update, one way or the other.

     
  • Nobody/Anonymous

    OK, more on this experiment…..

    Same program as above, but with:
    "dim test as word"

    When "Print test" is invoked, compiler runs successfully but assembler produces an error rejecting the asm code.

    Here is a snippet of the asm code produced by GCBasic:

    SYSDIV16START:
    clc
    rol SYSDIVMULTA
    rol SYSDIVMULTA_H
    rol SYSDIVMULTX
    rol SYSDIVMULTX_H
    mov SysTemp1,SYSDIVMULTX
    mov SysTemp1_H,SYSDIVMULTX_H
    sub SysTemp1,SYSDIVMULTB
    sbc SysTemp1_H,SYSDIVMULTB_H
    mov SYSDIVMULTX,SysTemp1
    mov SYSDIVMULTX_H,SysTemp1_H
    sbr SYSDIVMULTA,1<<0
    brbc C,ENDIF14
    cbr SYSDIVMULTA,1<<0
    mov SysTemp1,SYSDIVMULTX
    mov SysTemp1_H,SYSDIVMULTX_H
    add SysTemp1,SYSDIVMULTB
    adc SysTemp1_H,SYSDIVMULTB_H
    mov SYSDIVMULTX,SysTemp1
    mov SYSDIVMULTX_H,SysTemp1_H
    ENDIF14:
    dec SYSDIVLOOP
                    ……………………………

    The assembler is choking on this line:
    brbc C,ENDIF14

    From what I can determine from the AVR instruction set, it appears to me that "C" is an invalid argument for this instruction. It should be "s" or "k".

    Hugh, can you comment?

    Joe

     

Log in to post a comment.