Path:AVR-EN => Applications => LCD experimental board => Example include routine application linear
tn24_lcd experimental board small Applications of
AVR single chip controllers AT90S, ATtiny, ATmega and ATxmega
Experimental board with an ATtiny24/44/84 and an LCD
Logo

Example application of the include routines in linear programs for the ATtiny24/44/84 experimental board

Source code link: here.

;
; ***********************************************
; * tn24_lcd example source code for LCD access *
; * without interrupts with tn24_lcd_busy.inc   *
; * (C)2018 http://www.av-asm-tutorial,net      *
; ***********************************************
;
.nolist
.include "tn24def.inc" ; Define device ATtiny24
.list
;
; **********************************
;        H A R D W A R E
; **********************************
; Device: ATtiny24A, Package: 14-pin-PDIP_SOIC
;
;             ______
;          1 /      |14
;    VCC o--|       |--o GND
;          2|       |13
; LCD-RS o--|       |--o PA0
;          3|       |12
; LCD-RW o--|       |--o PA1
;          4|       |11
;  RESET o--|       |--o PA2
;          5|       |10
; LCD-EN o--|       |--o PA3
;          6|       |9
; LCD-D7 o--|       |--o LCD-D4
;          7|       |8
; LCD-D6 o--|       |--o LCD-D5
;           |_______|
;
; **********************************
;  P O R T S   A N D   P I N S
; **********************************
;
; (Port A port bits PA0..PA3 freely available)
;
; **********************************
;   A D J U S T A B L E   C O N S T
; **********************************
;
; Default controller clock frequency
;   max clock frequency: 8 MHz
;
.equ clock=1000000 ; Define clock frequency
;
; Delay between init and output mask
;   in multiples of 250 ms
;
.equ cLcdDelay = 20 ; Mask delay 5 seconds
;
; Switches for the use of LCD number
;   conversion and display routines.
;   If not used comment out the .set
;   directives with ;
;
.set sLcdDec8 = 1 ; Display 8 bit decimals
.set sLcdDec16 = 1 ; Display 16 bit decimals
.set sLcdHex8 = 1 ; Display 8 bit hexadecimals
.set sLcdHex16 = 1 ; Display 16 bit hexadecimals
.set sLcdBin8 = 1 ; Display 8 bit binaries
.set sLcdBin16 = 1 ; Display 16 bit binaries
.set LcdNmbr8 = 123 ; Display as 8 bit
.set LcdNmbr16 = 12345 ; Display as 16-Bit-Zahl
;
; Generate own characters on the LCD
;
.set sLcdChars = 1 ; Generate special chars and display
;
; **********************************
;  F I X  &  D E R I V.  C O N S T
; **********************************
;
; **********************************
;       R E G I S T E R S
; **********************************
;
; free: R0 to R15 (R0, R1 and R2 are used by
        some include routines, but are restored)
; rmp must be defined (include routines)
.def rmp = R16 ; Define multipurpose register
; free: R17 to R29
; used: R31:R30 = Z temporarily for include routines
;
; **********************************
;           S R A M
; **********************************
;
.dseg
.org SRAM_START
; (not used)
;
; **********************************
;       C O D E - S E G M E N T
; **********************************
;
.cseg
.org 000000
;
; **********************************
;  M A I N   P R O G R A M   I N I T
; **********************************
;
Main:
  ; Init stack
;  ldi rmp,High(RAMEND) ; Only with ATtiny84!
;  out SPH,rmp
  ldi rmp,Low(RAMEND)
  out SPL,rmp
  ; LCD init
  rcall LcdInit
  ; Display numbers in diverse formats
  .ifdef sLcdBin8 ; 8 bit binary?
    rcall LcdLine1
    ldi rmp,'0'
    rcall LcdChar
    ldi rmp,'b'
    rcall LcdChar
    ldi rmp,LcdNmbr8
    rcall LcdBin8
    ldi rmp,' '
    rcall LcdChar
    ldi rmp,'='
    rcall LcdChar
    .endif
  .ifdef sLcdHex8 ; 8 bit hexadecimal?
    ; Display 8 bit-hexadecimal in line 1
    ldi ZH,0 ; To line 1
    ldi ZL,cLcdColumns-7 ; To column (N-7)
    rcall LcdPos
    ldi rmp,'$'
    rcall LcdChar ; Write char on LCD
    ldi rmp,LcdNmbr8 ; Load number
    rcall LcdHex8
    .ifdef sLcdDec8
      ldi rmp,'=' ; Equals
      rcall LcdChar
      .endif
    .endif
  .ifdef sLcdDec8 ; Display 8 bit decimal?
    ; Display 8 bit decimal in line 1
    ldi ZH,0 ; To line 1
    ldi ZL,cLcdColumns-3 ; To the end of the line
    rcall LcdPos
    ldi rmp,LcdNmbr8 ; Load number
    rcall LcdDec8
    .endif
  .ifdef sLcdHex16 ; Display 16 bit hexadecimal?
    ; Display 16 bit hexadecimal in line 2
    ldi ZH,1 ; To line 2
    ldi ZL,9 ; To column 10
    rcall LcdPos
    ldi rmp,'$' ; Dollar for hex
    rcall LcdChar
    ldi ZH,High(LcdNmbr16) ; Load number
    ldi ZL,Low(LcdNmbr16)
    rcall LcdHex16
    .ifdef sLcdDec16
      ldi rmp,'='
      rcall LcdChar
      .endif
    .endif
  .ifdef sLcdDec16 ; Display 16 bit decimal?
    ldi ZH,1 ; Line 2
    ldi ZL,cLcdColumns-5
    rcall LcdPos
    ldi ZH,High(LcdNmbr16)
    ldi ZL,Low(LcdNmbr16)
    rcall LcdDec16
    .endif
  .ifdef sLcdBin16 ; Display 16 bit binary?
    rcall LcdLine3 ; To the start of line 3
    ldi rmp,'='
    rcall LcdChar
    ldi rmp,' '
    rcall LcdChar
    ldi ZH,High(LcdNmbr16)
    ldi ZL,Low(LcdNmbr16)
    rcall LcdBin16
    .endif
  .ifdef sLcdChars ; Display special chars?
    ldi ZH,High(2*CodeChars)
    ldi ZL,Low(2*CodeChars)
    rcall LcdChars
    rcall LcdLine4 ; To line 4
    ldi ZH,High(2*Codeline)
    ldi ZL,Low(2*Codeline)
    rcall LcdTextC
    .endif
;
Loop:
  rjmp Loop

;
; The LCD routines
;   tn24_lcd_busy.inc set to 4*20
;   and saved with a new name
;
.include "tn24_lcd_busy_4x20.inc"
;
; Special characters for LCD
;
.ifdef sLcdChars
  ;
  ; Tabelle der Codezeichen
  CodeChars:
  .db 64,0,0,0,0,10,10,12,8,16 ; Z = 0, micro
  .db 72,0,0,14,17,17,17,10,27,0 ; Z = 1, Omega
  .db 80,0,0,0,10,17,21,10,0,0 ; Z = 2, omega
  .db 88,0,1,27,1,1,0,0,0,0 ; Z = 3, power-1
  .db 0,0
  Codeline:
  .db '1',0,"F, R=8",1,", ",2,"=0.1s",3,0xFE,0xFE
  .endif
;
; End of source code
;



To the top of that page




Praise, error reports, scolding and spam please via the comment page to me. Spammers: please note that behind this is not a dump standard script but I personnally select the entries to be published.

©2018 by http://www.avr-asm-tutorial.net