Salut,
J'ai un programme de gestion d'un afficheur LCD inteligent avec un 8515 et je me pose une question comment se fait la communication avec le LCD sans passé par des IN PORT ou des OUT PORT ?
[code:1:645ed3144b]; ****************************** ***********************
; * Demonstrates the use of the Include routines *
; * LCD_INC.ASM for use with the LCD on board of the *
; * ATMEL STK200 (C) 1999 Gerhard Schmidt *
; * Report bugs to info@avr-asm-tutorial.net *
; ****************************** ***********************
;
.NOLIST
.INCLUDE "C:\avrtools\appnotes \8515def.inc"
.LIST
.def mpr=R16 ; My multipurpose register, required
; Reset-/Interrupt-Vectors
rjmp main
; Includes the LCD-routines, file must be in the same path
.INCLUDE "LCD_INC.ASM"
; Main program
main:
ldi mpr,LOW(RAMEND) ; Set up stack
out SPL,mpr
ldi mpr,HIGH(RAMEND)
out SPH,mpr
ldi mpr,0xC0 ; Switch on external SRAM and WAIT
out MCUCR,mpr
rcall lcd_cl ; Clears display
rcall lcd_st ; Standard display mode
ldi mpr,0x05; Cursor position to line 1, col 5
rcall lcd_sc
ldi mpr,'H' ; Output Hello World
rcall lcd_ch
ldi mpr,'e'
rcall lcd_ch
ldi mpr,'l'
rcall lcd_ch
rcall lcd_ch
ldi mpr,'o'
rcall lcd_ch
ldi mpr,0x45 ; Cursor position to line 2, col 5
rcall lcd_sc
ldi mpr,'W'
rcall lcd_ch
ldi mpr,'o'
rcall lcd_ch
ldi mpr,'r'
rcall lcd_ch
ldi mpr,'d'
rcall lcd_ch
ldi mpr,'!'
rcall lcd_ch
rcall lcd_on
loop:
rjmp loop ; Uff! Next week we learn how to create and read a table[/code:1:645ed3144b]
[code:1:645ed3144b]; ****************************** **************
; * LCD-Interface routines for multi-purpose *
; * use with the ATMEL STK200 board, Version *
; * 0.1 Beta, (C) 1999 Gerhard Schmidt *
; * Report bugs to info@avr-asm-tutorial.net *
; ****************************** **************
;
; Purpose:
; Include file for the AVR assembler
; Supplies the common routines to drive an
; LCD connected to the ATMEL STK200 board
; Works best and is compatible to external
; SRAM on that board (up to 32 kB)
;
; Requires:
; mpr ... Multipurpose register, anything
; between R16 and R31, unchanged
; after all routines
; Memory-mapped operation of the LCD
; Setup of the software stack due to the use
; of relative subroutines and PUSH/POP
; LCD properly connected to the board, otherwise
; processor hangs around and waits for
; the busy flag to go down! (no timeout!)
; 39 words of program space
;
; Interfaces:
; lcd_wt Waits indefinately until the busy
; flag of the LCD is off
; lcd_fc Sends the command byte in register
; mpr to the LCD after busy is off
; lcd_cl Clears the LCD and sets cursor to
; the home position, after busy is off
; lcd_st Sets the LCD to 8-bit-transfer,
; freezes the display window and sets
; cursor to increment after busy is off
; lcd_sc Sets cursor to the display position
; in register mpr (Line 1: 00 .. 0F hex,
; Line 2: 40 .. 4F hex)
; lcd_ch Outputs the character in register
; mpr to the LCD after busy is off
; lcd_on Sets display on, cursor on and blink
;
; Adress definitions:
.equ lcd_rs = 0x8000 ; Register select = 0 adress
.equ lcd_ds = 0xC000 ; Register select = 1 adress
;
; Subroutines
;
; Wait until LCD is not busy any more
;
lcd_wt:
push mpr ; save register
lcd_wt1:
lds mpr,lcd_rs ; read busy flag
rol mpr ; Busy = Bit 7 into Carry
brcs lcd_wt1 ; still busy, repeat
pop mpr ; restore register
ret
;
; Outputs the function command in mpr to the LCD
;
lcd_fc:
rcall lcd_wt ; Wait until not busy any more
sts lcd_rs,mpr ; Command byte to LCD
ret
;
; Clears LCD and sets cursor to home position
;
lcd_cl:
push mpr ; save register
ldi mpr,0x01 ; the clear command
rcall lcd_fc ; output to LCD command
pop mpr ; restore register
ret
;
; Sets LCD to 8-bit-mode, display window freeze and
; cursor incrementation (standard mode)
;
lcd_st:
push mpr ; save register
ldi mpr,0b00111000 ; 8-Bit-transfer
rcall lcd_fc ; to LCD command
ldi mpr,0b00000110 ; Increment, display freeze
rcall lcd_fc ; to LCD
ldi mpr,0b00010000 ; Cursor move, not shift
rcall lcd_fc ; to LCD
pop mpr ; restore register
ret
;
; Sets cursor on the LCD to a certain display position in mpr
;
lcd_sc:
push mpr ; save position
ori mpr,0x80 ; set bit 7 of the position
rcall lcd_fc ; position to LCD
pop mpr ; restore register
ret
;
; Sends a character in mpr to the display at the current
; position, position is incremented after write
;
lcd_ch:
rcall lcd_wt ; wait for not busy
sts lcd_ds,mpr ; transfer character to LCD-Display
ret
;
; Sets LCD display on, cursor on and blink on
;
lcd_on:
push mpr ; save register
ldi mpr,0b00001111 ; command byte
rcall lcd_fc ; to LCD
pop mpr ; restore register
ret[/code:1:645ed3144b]
Merci d'avance pour vos explications
-----