Path: Home => AVR-EN => Applications => LCD experimental board => Example include routine application with interrupts   Diese Seite in Deutsch: Flag DE Logo
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

Example application of the include routines in interrupt-driven programs for the ATtiny24/44/84 experimental board

Source code link: here. The program is configured for a single-line LCD with eight characters per line and for operation at 8 MHz clock frequency (CLDDIV8 fuse cleared).

The LCD routine described here has been improved and can be replaced by the version described here. This provides a more universally applicable routine that can be adapted to the here described hardware.

;
; ***********************************************
; * Example application of the include routines *
; * with interrupts and tn24_lcd_busy.inc       *
; * (C)2018 http://www.av-asm-tutorial,net      *
; ***********************************************
;
; Works with AVR types: ATtiny24/44/84
; If ATtiny84: set SPH in program main
.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
; **********************************
;
; Controller clock frequency 8 Mhz (fuse
;   CLKDIV8 cleared)
;   at maximum permissible clock frequency
;
.equ clock=8000000 ; 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 ;
;
; Routines switched ON:
.set sLcdDec8 = 1 ; Display 8 bit decimals
.set sLcdHex8 = 1 ; Display 8 bit hexadecimals
;
; Routines switched OFF:
;.set sLcdDec16 = 1 ; Display 16 bit decimals
;.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 (unused)
;
; Generate own characters on the LCD
;
; Switched OFF:
;.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
; **********************************
;
; frei: R0 bis R15 (R0 und R1 werden von Include-
;       routinen benutzt, aber wieder hergestellt)
; rmp muss definiert sein (Include-Routinen)
.def rmp = R16 ; Define multipurpose register
; frei: R17 bis R29
; benutzt: R31:R30 = Z temporaer fuer Include-Routinen
;
; **********************************
;           S R A M
; **********************************
;
.dseg
.org SRAM_START
; (Not used)
;
; **********************************
;      C O D E - S E G M E N T
; **********************************
;
.cseg
.org 000000
;
; ***********************************
; R E S E T  &  I N T - V E C T O R S
; ***********************************
  rjmp Main ; Reset vector
  reti ; EXT_INT0
  reti ; PCI0
  reti ; PCI1
  reti ; WATCHDOG
  reti ; ICP1
  reti ; OC1A
  reti ; OC1B
  reti ; OVF1
  reti ; OC0A
  reti ; OC0B
  reti ; OVF0
  reti ; ACI
  reti ; ADCC
  reti ; ERDY
  reti ; USI_STR
  reti ; USI_OVF
;
; **********************************
;  I N T - S E R V I C E   R O U T .
; **********************************
;
; **********************************
;  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 ; in Zeile 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
; ...
  sei ; Enable interrupts
;
; **********************************
;    P R O G R A M   L O O P
; **********************************
;
Loop:
  rjmp loop
;
; The LCD routines
;   tn24_lcd_busy.inc set to 1x8 size
;   and saved as a new file
;
.include "tn24_lcd_busy_1x8.inc"
;
; 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