![]() |
Anwendungen von AVR-Einchip-Prozessoren AT90S, ATtiny, ATmega und ATxmega Experimentierboard mit einem ATtiny24/44/84 und einer LCD Beispielanwendung des Include-Routinen-Quellcodes (mit Interrupts) |
; ; ****************************************** ; * Beispiel-LCD-Ansteuerungsprogramm * ; * mit Interrupts mit tn24_lcd_busy.inc * ; * (C)2018 http://www.av-asm-tutorial,net * ; ****************************************** ; ; Zulaessige Typen: ATtiny24/44/84 .nolist .include "tn24def.inc" ; Define device ATtiny24 .list ; ; ********************************** ; H A R D W A R E ; ********************************** ; ; ********************************** ; P O R T S A N D P I N S ; ********************************** ; ; (Port A Portbits PA0..PA3 frei verfuegbar) ; ; ********************************** ; A D J U S T A B L E C O N S T ; ********************************** ; ; Default-Prozessor-Taktfrequenz ; maximal zulaessige Taktfrequenz: 8 MHz ; bei hoeheren Taktfrequenzen: Makro LcdEDly ; entsprechend erweitern! ; .equ clock=8000000 ; Define clock frequency ; ; Verzoegerung zwischen der LCD-Init-Textausgabe ; und der LCD-Masken-Textausgabe, in Vielfachen ; von 250 ms (maximal 50!) ; .equ cLcdDelay = 8 ; Maskenausgabeverzoegerung ; ; Schalter fuer die Verwendung von ; LCD-Ausgabe-Routinen fuer Zahlen ; Nicht verwendete Ausgabe-Routinen mit ; ; auskommentieren ; .set sLcdDec8 = 1 ; Ausgabe von 8-Bit-Dezimalzahlen ;.set sLcdDec16 = 1 ; Ausgabe von 16-Bit-Dezimalzahlen .set sLcdHex8 = 1 ; Ausgabe von 8-Bit-Hexadecimalzahlen ;.set sLcdHex16 = 1 ; Ausgabe von 16-Bit-Hexadezimalzahlen ;.set sLcdBin8 = 1 ; Ausgabe von 8-Bit-Binaerzahlen ;.set sLcdBin16 = 1 ; Ausgabe von 16-Bit-Binaerzahlen .set LcdZahl8 = 123 ; Auszugebende 8-Bit-Zahl .set LcdZahl16 = 12345 ; Auszugebende 16-Bit-Zahl ; ; Erzeugen von eigenen Zeichen auf der LCD ; ;.set sLcdChars = 1 ; Erzeuge eigene Zeichen und zeige an ; ; ********************************** ; 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 ; ; ********************************** ; 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: ; Stapel initiieren ldi rmp,Low(RAMEND) out SPL,rmp ; LCD initiieren rcall LcdInit ; ; Ausgabe von Zahlen in diversen Formaten ; .ifdef sLcdBin8 ; 8-Bit-Binaerzahl ausgeben? rcall LcdLine1 ldi rmp,'0' rcall LcdChar ldi rmp,'x' rcall LcdChar ldi rmp,LcdZahl8 rcall LcdBin8 ldi rmp,' ' rcall LcdChar ldi rmp,'=' rcall LcdChar .endif .ifdef sLcdHex8 ; 8-Bit-Hexadezimalzahl ausgeben? ; 8-Bit-Hexadezimalzahl in Zeile 1 ausgeben ldi ZH,0 ; in Zeile 1 ldi ZL,cLcdColumns-7 ; in die Mitte der Zeile rcall LcdPos ldi rmp,'$' rcall LcdChar ; an LCD ausgeben ldi rmp,LcdZahl8 ; Auszugebende Zahl rcall LcdHex8 .ifdef sLcdDec8 ldi rmp,'=' ; Gleicheitszeichen rcall LcdChar .endif .endif .ifdef sLcdDec8 ; 8-Bit-Dezimalzahl ausgeben? ; 8-Bit-Dezimalzahl in Zeile 1 ausgeben ldi ZH,0 ; in Zeile 1 ldi ZL,cLcdColumns-3 ; ans Ende der Zeile rcall LcdPos ldi rmp,LcdZahl8 ; Auszugebende Zahl rcall LcdDec8 .endif .ifdef sLcdHex16 ; 16-Bit-Hexadezimalzahl ausgeben? ; 16-Bit-Hexadezimalzahl in Zeile 2 ausgeben ldi ZH,1 ; Zeile 2 ldi ZL,9 ; in zehnte Spalte rcall LcdPos ldi rmp,'$' ; Dollarzeichen fuer Hex rcall LcdChar ldi ZH,High(LcdZahl16) ; Auszugebende Zahl ldi ZL,Low(LcdZahl16) rcall LcdHex16 .ifdef sLcdDec16 ldi rmp,'=' rcall LcdChar .endif .endif .ifdef sLcdDec16 ; 16-Bit-Dezimalzahl ausgeben? ldi ZH,1 ; Zeile 2 ldi ZL,cLcdColumns-5 rcall LcdPos ldi ZH,High(LcdZahl16) ldi ZL,Low(LcdZahl16) rcall LcdDec16 .endif .ifdef sLcdBin16 ; 16-Bit-Binaerzahl ausgeben? rcall LcdLine3 ; An den Anfang von Zeile 3 ldi rmp,'=' rcall LcdChar ldi rmp,' ' rcall LcdChar ldi ZH,High(LcdZahl16) ldi ZL,Low(LcdZahl16) rcall LcdBin16 .endif .ifdef sLcdChars ldi ZH,High(2*Codezeichen) ldi ZL,Low(2*Codezeichen) rcall LcdChars rcall LcdLine4 ; in Zeile 4 ldi ZH,High(2*Codezeile) ldi ZL,Low(2*Codezeile) rcall LcdTextC .endif ; ... sei ; Enable interrupts ; ; ********************************** ; P R O G R A M L O O P ; ********************************** ; Loop: rjmp loop ; ; Die LCD-Routinen ; .include "tn24_lcd_busy_1x8.inc" ; ; Spezialzeichen fuer LCD ; .ifdef sLcdChars ; ; Tabelle der Codezeichen Codezeichen: .db 64,0,0,0,0,10,10,12,8,16 ; Z = 0, mikro .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, hoch-1 .db 0,0 Codezeile: .db '1',0,"F, R=8",1,", ",2,"=0.1s",3,0xFE,0xFE .endif ; ; End of source code ;
Seitenanfang |
---|