cs_malabar969
Messages postés2Date d'inscriptionsamedi 7 février 2009StatutMembreDernière intervention27 novembre 2010
-
26 nov. 2010 à 17:21
cs_malabar969
Messages postés2Date d'inscriptionsamedi 7 février 2009StatutMembreDernière intervention27 novembre 2010
-
27 nov. 2010 à 02:33
Bonjour,
Je dois programmer en ASM un micro 80c535.Le programme est en deux partie.Une partie pour l'affichage LCD type HD4480 HITACHI avec menu et commande et l'autre partie, commande d'une platine simulant un croissement avec 4 feux tricolores, 8 feux bicolore pour 4 passages piétons avec 8 boutons pour piétons. Il y a aussi en bout de l’une des routes un passage à niveau (train), sur chaque coté du passage a niveau il ya deux feus, ils sont commandé par deux capteur se trouvant sur chacune sur une des deux voie.
Malheureusement je ne suis pas un expert en assembleur.
PORT POUR PLATINE
HAR P4.0 ;A13/A33 --> HAR Feu-Rouge- Horizontal-Automobile
HAO P4.1 ;A12/A32 --> HAO Feu-Orange-Horizontal-Automobile
HAG P4.2 ;A11/A31 --> HAG Feu-Vert-Horizontal-Automobile
HFR P4.3 ;F12/F44/F32/F24 --> HFR Feu- Rouge-Horizontal-Piéton
HFG P4.4 ;F11/F43/F31/F23 --> HFG Feu-Vert-Horizontal-Piéton
ZA23 P4.5 ;A25/A35 --> ZA23 Lampe- Train-23
ZA32 P4.7 ;A24/A34 --> ZA32 Lampe- Train-32
VAR P5.0 ;A23/A43 --> VAR Feu-Rouge- Vertical -Automobile
VAO P5.1 ;A22/A42 --> VAO Feu-Orange-Vertical-Automobile
VAG P5.2 ;A21/A41 --> VAG Feu-Vert-Vertical-Automobile
VFR P5.3 ;F14/F22/F42/F34 --> VFR Feu-Rouge-Vertical-Piéton
VFG P5.4 ;F13/F21/F33/F41 --> VFG Feu-Vert-Vertical-Piéton
S P5.2 ; S31/S21 --> S Capteur-Passage-train
THP P5.3 ;T12/T42/T22/T31 --> TH Taster- Horizontal- Piéton
TVP P5.4 ;T11/T21/T32/T41 --> TV Taster - Vertical- Piéton
PORT POUR LCD
E P6.0
RW P6.1
RS P6.2
DB4 P1.4
DB5 P1.5
DB6 P1.6
DB7 P1.7
Port pour clavier
B1 P6 .3
B2 P6.4
B3 P6.5
Je voudrai garder le port P3 pour les interruptions.
Je ne sais pas comment programmer un menu en ASM qui me servira de commande pour ma platine.
Exemple:
(Affichage LCD)
COMMANDE DE SIGNALISATION, CARREFOUR, PASSAGE PIETON ET PASSAGE A NIVEAU
MENU :
CIRCULATION NORMAL (1)
CIRCULATION HEURE DE POINTE (2)
CIRCULATION DE NUIT (3)
L’utilisateur choisi le menu de son choix, par le biais d’un clavier.
Pouvez-vous m’aider s’il vous plait. Des morceaux de code ainsi que des explications seraient les biens venus.
J’ai trouvé un code qui fonctionne pour l’affichage du LCD, mais je n’arrive pas à faire défiler un texte sup a 16 caractères.
; ***********************************************************
; * Demo-program for driving Display-Unit 2 *
; * (MCLS-modular/PSD1-configuration) *
; * ------------------------------------------------------- *
; * LCD-UNIT in 4-bit mode at PSD1-module *
; * (HD44780-compatible display controller) *
; * ------------------------------------------------------- *
; * Display-Unit 2 in 4-bit mode at PSD1-module *
; * (HD44780-compatible display controller) *
; * a) Data signals *
; * DB7 - P1.7 *
; * DB6 - P1.6 *
; * DB5 - P1.5 *
; * DB4 - P1.4 *
; * b) control signals *
; * E - P4.0 ; Enable, 1-0 for data transfer *
; * R/W - P4.1 ; Read/Write, 0 for write *
; * ; 1 for read *
; * RS - P4.2 ; Select register *
; * ; 0 - Data is command *
; * ; 1 - Data for display RAM *
; ***********************************************************
; * HAG 17.10.2000 *
; ***********************************************************
; -----------------------------------------------------------
text_zeile1:
mov a,#00h+2 ; Cursor position 1st. line
call CURSOR_POS
mov b,#000h ; Reset Offset for text
mov dptr,#text1 ; Pointer to start of text
m00: mov a,b ; Offset to a
movc a,@a+dptr ; Access to text element
jz m01 ; End ID reached ?
; If Yes, then to endless loop
call WRITE_DREG ; Write character in LCD data register
call wait_short ; Wait 100µs
inc b ; Offset +1
jmp m00 ; Back to m00 (repeat loop)
m01: ret
; -----------------------------------------------------------
; -----------------------------------------------------------
text_zeile2:
mov a,#40h ; Cursor position 2nd. line
call CURSOR_POS
mov b,#000h ; Reset Offset for text
mov dptr,#text2 ; Pointer to start of text
m02: mov a,b ; Offset to a
movc a,@a+dptr ; Access to text element
jz m03 ; End ID reached ?
; If Yes, then to endless loop
call WRITE_DREG ; Write character in LCD data register
call wait_short ; Wait 100µs
inc b ; Offset +1
jmp m02 ; Repeat loop
m03: ret
; -----------------------------------------------------------
; -----------------------------------------------------------
; Demo-text
text1 db "MCLS-modular!",00
text2 db "Demo LCD-UNIT",00
; -----------------------------------------------------------
; -----------------------------------------------------------
; # #
; # Control signal assignment #
; # #
; -----------------------------------------------------------
call WAIT_FOR_READY
mov a,#00001100b ; Display on
; Cursor off, Flash off
call WRITE_CREG_4BIT
call WAIT_FOR_READY
ret
; -----------------------------------------------------------
; -----------------------------------------------------------
; # CURSOR_HOME #
; # Cursor to Start position #
; -----------------------------------------------------------
CURSOR_HOME:
mov a,#00000010b
call WRITE_CREG_4BIT
call wait_1ms
ret
; -----------------------------------------------------------
; -----------------------------------------------------------
; # CURSOR_POS #
; # Position the cursor #
; # Addresses for line 1: 00h - 1fh #
; # Addresses for line 2: 40h - 4fh #
; # Prepare the address of the character via the acc. #
; -----------------------------------------------------------
CURSOR_POS:
orl a,#10000000b ; Set bit 7
call WRITE_CREG_4BIT
call wait_1ms
ret
; -----------------------------------------------------------
; -----------------------------------------------------------
; # WRITE_CREG_8BIT #
; # Control word for LCD-Unit (8-bit Mode) #
; -----------------------------------------------------------
WRITE_CREG_8BIT:
push b
clr RS ; Data is command word
clr RW ; Write to display
clr E ; First time as 0
nop
setb E ; E in initial state
anl a,#0f0h ; Reset LT in control word
anl p1,#0fh ; Reset HT at Port 1
orl p1,a ; Combine tetrades
clr E ; Now, transfer edge
nop
orl p1,#0f0h ; Set HT Port 1
pop b
ret
; -----------------------------------------------------------
; -----------------------------------------------------------
; # WRITE_CREG_4BIT #
; # Control word for LCD-Unit (4-bit Mode) #
; -----------------------------------------------------------
WRITE_CREG_4BIT:
push b
mov b,a ; Buffer data in b
clr RS ; Data is command word
clr RW ; Write to display
clr E ; First time as 0
nop
setb E ; E in initial state
anl a,#0f0h ; Reset LT in control word
anl p1,#0fh ; Reset HT at Port 1
orl p1,a ; Combine tetrades
clr E ; Now, transfer edge
nop
setb E
mov a,b
swap a
anl a,#0f0h
anl p1,#0fh
orl p1,a
clr E
nop
orl p1,#0f0h
pop b
ret
; -----------------------------------------------------------
; -----------------------------------------------------------
; # WAIT_FOR_READY #
; # Wait until LCD-UNIT is ready #
; -----------------------------------------------------------
WAIT_FOR_READY:
push acc
wa0:
call READ_CREG
jb acc.7,wa0
pop acc
ret
; -----------------------------------------------------------
; -----------------------------------------------------------
; # READ_CREG #
; # Read the control register #
; -----------------------------------------------------------
READ_CREG:
push b
orl p1,#0f0h
clr RS
setb RW
clr E
nop
setb E
nop
mov a,p1
anl a,#0f0h
mov b,a
clr E
nop
setb E
nop
mov a,p1
anl a,#0f0h
swap a
orl a,b
clr E
nop
clr RW
pop b
ret
; -----------------------------------------------------------
; -----------------------------------------------------------
; # WRITE_DREG #
; # Write to the data register #
; # Prepare ASCII-character code via acc. #
; -----------------------------------------------------------
WRITE_DREG:
push b
mov b,a
setb RS
clr RW
clr E
nop
setb E
anl a,#0f0h
anl p1,#0fh
orl p1,a
clr E
nop
setb E
mov a,b
swap a
anl a,#0f0h
anl p1,#0fh
orl p1,a
clr E
nop
clr RS
nop
orl p1,#0f0h
pop b
ret
; -----------------------------------------------------------
; -----------------------------------------------------------
; # Time delay for LCD-UNIT #
; -----------------------------------------------------------
; Wait for about 1 s
wait_long:
mov r5,#100
w04: call wait_10ms ; 10ms
djnz r5,w04 ; 2µs
ret ; 2µs
; Wait for about 100µs
wait_short:
mov r6,#48 ; 2µs
w00: djnz r6,w00 ; 96µs
ret ; 2µs
wait_1ms:
mov r6,#10
w01: call wait_short
djnz r7,w01
ret
wait_2ms:
mov r6,#20
w02: call wait_short
djnz r7,w02
ret
cs_patatalo
Messages postés1466Date d'inscriptionvendredi 2 janvier 2004StatutModérateurDernière intervention14 février 20142 26 nov. 2010 à 23:20
salut,
je n'y connais pas grand chose mais en faisant chauffer mes méninges, il semblerait que les fonctions text_zeileX qui lisent les caractères soient plutôt limitées par un caractère 0 (nul).
De plus, les zones de texte semblent prévoir un espace de 64 caractères.
La limitation serait-elle materielle ? Le registre b est-il bien un octet ? valeur max (0..255) ?