electronicus
Full Member level 4
Haw can I change the number of the modules, from 11 too 22, in this "asm" file?
**************************
;**********************************************************
;* LEDFONT.ASM V2.1 *
;* LED moving font *
;* Several MAX7219 are cascaded, modules consist of *
;* 8x8 LEDs; character font 5x8 *
;* Assembler program for 8051-compatible controller, *
;* e.g. AT89C51, quartz frequency 11,0592 MHz *
;* The following program controls up to 11 modules. *
;**********************************************************
;* World Of Electronics *
;* **broken link removed** *
;* woe@topmail.de *
;* (c) WOE, 1999 *
;**********************************************************
DIN equ p1.0 ; DIN at Port 1.0
CLCK equ p1.1 ; CLK at Port 1.1
LOAD equ p1.2 ; LOAD at Port 1.2
scl equ p3.5 ; SCL for I2C-Bus
sda equ p3.7 ; SDA for I2C-Bus
jumper_ser equ p1.6 ; Jumper for serial download
jumper_eep equ p3.2 ; Jumper for EEPROM-mode
jumper_baud equ p3.3 ; Jumper for serial baudrate
ser_wait equ p3.4 ; serial handshake
led equ p1.7 ; LED for serial download
MODULE equ 11 ; number of 8x8 LED modules (max. 11)
; Flags (in bit area, adr. 20h internal RAM)
i2c_ack_in equ 0
i2c_ack_out equ 1
z_abfrage equ 2
eep_mode equ 3
z_anz_h equ 21h ; number of characters
z_anz_l equ 22h ; (16 bit value)
zeichen_h equ 23h ; character counter
zeichen_l equ 24h ; (16 bit value)
sp_off_l equ 25h ; Offset for character font
sp_off_h equ 26h ; (16 bit value)
anfang:
setb i2c_ack_out
setb i2c_ack_in
call clear_disp
call ledout_ini ; Initialization
jb jumper_ser,lauf
jmp ser_load
lauf:
jb jumper_eep,rom_mode
setb eep_mode
call read_z_anz ; read number of chars out of EEPROM
jmp anz_ende
rom_mode:
clr eep_mode
call read_anz_rom ; read number of chars out of ROM
anz_ende:
mov r0,#40
clr a
clr_loop:
mov @r0,a ; clear memory cells 40...127 (internal RAM)
inc r0
cjne r0,#128,clr_loop
lauf_loop:
call ledout_ini
mov zeichen_h,#0 ; character counter HIGH
mov zeichen_l,#0 ; character counter LOW
clr z_abfrage
mov r5,#0 ; r5: column counter
jnb eep_mode,rom_dat
call read_eeprom
jmp read_end
rom_dat:
call read_rom
read_end:
spa:
jnb acc.7,z_ascii
call convert_char
jmp z_ok
z_ascii:
clr c
subb a,#32
jnc z_ok
clr a
z_ok:
mov b,#5
mul ab
mov sp_off_l,a ; Offset for column
mov sp_off_h,b ; (16 bit value)
wdh:
mov r1,#127
mov r0,#126
shift_ram:
mov a,@r0
mov @r1,a
dec r1
dec r0
cjne r1,#40,shift_ram
cjne r5,#5,sp_calc
mov 40,#0 ; LED-column on the right side
mov r5,#0
setb z_abfrage
inc zeichen_l
mov a,#0
cjne a,zeichen_l,x1
inc zeichen_h
x1:
jnb eep_mode,rom_dat2
call read_eeprom
jmp read_end2
rom_dat2:
call read_rom
read_end2:
spal:
jnb acc.7,z_ascii2
call convert_char
jmp z_ok2
z_ascii2:
clr c
subb a,#32
jnc z_ok2
mov a,#0
z_ok2:
mov b,#5
mul ab
mov sp_off_l,a
mov sp_off_h,b
jmp l1
sp_calc:
mov dptr,#spalten
mov a,sp_off_l
add a,dpl
jnc y1
inc dph
y1:
mov dpl,a
mov a,sp_off_h
add a,dph
mov dph,a
mov a,r5
movc a,@a+dptr
mov 40,a ; LED-column on the right side
inc r5
l1:
matrix:
mov r2,#8 ; 8 columns
mov r6,#47 ; left LED-column of the 8x8-module on the right
led_10:
mov b,#((MODULE-1)*8)
dispout:
mov a,r6
add a,b
mov r1,a
mov a,@r1
mov r3,a
call ledout
mov a,b
clr c
subb a,#8
mov b,a
jnc dispout
setb LOAD ; all MAX7219 store their data
clr LOAD
dec r6
djnz r2,led_10 ; all 8 columns of a module
call zeit ; delay
jnb z_abfrage,wdh_jump
clr z_abfrage
mov a,z_anz_l
cjne a,zeichen_l,wdh_jump
mov a,z_anz_h
cjne a,zeichen_h,wdh_jump
jmp lauf_loop
wdh_jump:
jmp wdh
ser_load:
jnb jumper_baud,b1200 ; sample jumper for baudrate
b9600:
mov th1, #0fdh ; 9600 Baud
mov tl1, #0fdh
jmp ser
b1200:
mov th1,#0e8h ; 1200 Baud
mov tl1,#0e8h
ser:
mov tmod, #20h
mov scon, #50h
setb tr1
mov a, sbuf
clr ri
clr led ; LED Download on
mov z_anz_h,#0
mov z_anz_l,#0
mov r7,#2 ; data in EEPROM starts at address 2
mov r6,#0a0h
clr ser_wait
wait_data:
jb p3.0,no_startbit
setb ser_wait
no_startbit:
jb ri,ri_ok
jmp wait_data
ser_wdh:
clr ser_wait
mov r4,#3
w3:
mov r3,#0
w2:
mov r2,#0
w1:
jb p3.0,no_start
setb ser_wait
no_start:
jb ri,ri_ok
djnz r2,w1
djnz r3,w2
djnz r4,w3
jmp ser_end
ri_ok:
mov a,sbuf
clr ri
setb ser_wait
setb led ; LED off
mov b,a
call i2c_start
mov a,r6 ; I2C-address EEPROM
call i2c_send
mov a,r7 ; address in EEPROM
call i2c_send
mov a,b ; data for EEPROM
call i2c_send
call i2c_stop
call wait_eeprom
inc r7
cjne r7,#0,s1
inc r6
inc r6
s1:
inc z_anz_l
mov a,z_anz_l
cjne a,#0,s2
inc z_anz_h
s2:
mov r5,z_anz_h
cjne r5,#7h,ser_wdh
cjne a,#0FEh,ser_wdh
ser_end:
call i2c_start
mov a,#0a0h
call i2c_send
mov a,#0
call i2c_send
mov a,z_anz_h
call i2c_send
call i2c_stop
call wait_eeprom
call i2c_start
mov a,#0a0h
call i2c_send
mov a,#1
call i2c_send
mov a,z_anz_l
call i2c_send
call i2c_stop
call wait_eeprom
setb ser_wait
blink:
cpl led
mov r7,#2
bl1:
mov r6,#0
bl2:
mov r5,#0
bl3:
djnz r5,bl3
djnz r6,bl2
djnz r7,bl1
jmp blink
read_eeprom: ; read actual character out of EEPROM
push 6
push 7
mov r6,zeichen_h
mov r7,zeichen_l
mov a,r7
add a,#2
jnc no_inc
inc r6
no_inc:
mov r7,a
mov a,r6
rl a
orl a,#0a0h
mov r6,a
call i2c_start
call i2c_send
mov a,r7
call i2c_send
call i2c_start
mov a,r6
inc a
call i2c_send
setb i2c_ack_out ; no ACK
call i2c_read
call i2c_stop
pop 7
pop 6
ret
read_rom: ; read actual character out of ROM
mov dptr,#zeichen
mov a,dpl
add a,zeichen_l
jnc no_inc_dph
inc dph
no_inc_dph:
mov dpl,a
mov a,dph
add a,zeichen_h
mov dph,a
clr a
movc a,@a+dptr
ret
read_z_anz: ; read number of chars out of EEPROM
call i2c_start
mov a,#0a0h
call i2c_send
mov a,#0
call i2c_send
call i2c_start
mov a,#0a1h
call i2c_send
clr i2c_ack_out
call i2c_read
mov z_anz_h,a
setb i2c_ack_out ; no ACK
call i2c_read
mov z_anz_l,a
call i2c_stop
ret
read_anz_rom: ; read number of chars out of ROM
mov dptr,#z_anz_rom
clr a
movc a,@a+dptr
mov z_anz_h,a
mov a,#1
movc a,@a+dptr
mov z_anz_l,a
ret
convert_char:
cjne a,#132,co1
mov a,#96 ; „
ret
co1:
cjne a,#148,co2
mov a,#97 ; ”
ret
co2:
cjne a,#129,co3
mov a,#98 ;
ret
co3:
cjne a,#142,co4
mov a,#99 ; Ž
ret
co4:
cjne a,#153,co5
mov a,#100 ; ™
ret
co5:
cjne a,#154,co6
mov a,#101 ; š
ret
co6:
cjne a,#225,co7
mov a,#102 ; á
ret
co7:
clr a ; otherwise blank character
ret
;********************************************************
; Initialization: (uses R1, R2, R3, Accu)
ledout_ini:
clr DIN
clr CLCK
clr LOAD
;Decode mode at digit 0-7 = normal:
mov r2,#09h ; Address of Decode Mode Register
mov r3,#0h ; no decode
mov r1,#MODULE
decode:
call ledout
djnz r1,decode ; all modules
setb LOAD
clr LOAD
;set intensity on maximum:
mov r2,#0Ah ; Address of Intensity Register
mov r3,#0Fh ; max. intensity
mov r1,#MODULE
intens:
call ledout
djnz r1,intens ; all modules
setb LOAD
clr LOAD
;set Scan Limit on 8 active displays:
mov r2,#0Bh ; Address of Scan Limit Register
mov r3,#07h ; 8 digits
mov r1,#MODULE
scanlim:
call ledout
djnz r1,scanlim ; all modules
setb LOAD
clr LOAD
;Display test mode = off:
mov r2,#0Fh ; Address of Display Test Register
mov r3,#0h ; normal operation
mov r1,#MODULE
distest:
call ledout
djnz r1,distest ; all modules
setb LOAD
clr LOAD
;disable Shutdown = switch on display:
mov r2,#0Ch ; Address of Shutdown Register
mov r3,#01h ; normal operation
mov r1,#MODULE
shutd:
call ledout
djnz r1,shutd ; all modules
setb LOAD
clr LOAD
ret
;*************************************************
; clear complete display
clear_disp:
push 1
push 2
push 3
clr DIN
clr CLCK
clr LOAD
mov r2,#8 ; 8 Digits
led_ini_10:
mov r3,#0 ; data = 0
mov r1,#MODULE
modul:
call ledout
djnz r1,modul ; all modules
setb LOAD
clr LOAD
djnz r2,led_ini_10
pop 3
pop 2
pop 1
ret
;*************************************************
; send data to MAX7219 (without LOAD impulse!)
; Parameters:
; R2 = Address byte for MAX7219
; R3 = Data byte for MAX7219
ledout: push acc
push 0
push 1
mov acc,r2
mov r1,#2 ;2x 8 bits
lo_5: mov r0,#8 ;ever 8 bits
lo_10: jb acc.7,lo_20
clr DIN ;send 0
jmp lo_30
lo_20: setb DIN ;send 1
lo_30: setb CLCK ;generate clock
clr CLCK
rl a ;next bit
djnz r0,lo_10 ;(8 times)
mov a,r3 ;Data byte in accu
djnz r1,lo_5 ;once again, but now with data byte
pop 1
pop 0
pop acc
ret
;********************************************************
; delay
zeit:
push acc
push b
mov b,#0eh ; start value of register B can be
z1: mov a,#0ffh ; increased for slower moving speed
z2: nop
nop
nop
nop
djnz acc,z2
djnz b,z1
pop b
pop acc
ret
wait_eeprom:
push 5
push 6
mov r6,#50
w_eep1:
mov r5,#100
w_eep2:
djnz r5,w_eep2
djnz r6,w_eep1
pop 6
pop 5
ret
i2c_start: ; I2C Start condition
setb sda
nop
setb scl
call i2c_wait
clr sda ; Data = 0 (Start)
nop
clr scl ; Clock = 0
ret
i2c_stop: ; I2C Stop condition
setb scl ; Clock = 1
nop
setb sda ; Data = 1 (Stop)
ret
i2c_send: ; send 1 data byte (Accu) via I2C
push 3
mov r3,#8
i2c_sloop:
rlc a
mov sda,c
nop
setb scl
call i2c_wait
clr scl
djnz r3,i2c_sloop
nop
setb sda
nop
setb scl
call i2c_wait
mov c,sda ; read Acknowledge-bit
mov i2c_ack_in,c
clr scl
nop
clr sda
pop 3
ret
i2c_read: ; receive 1 data byte via I2C (Accu)
push 3
mov r3,#8
clr a
setb sda
i2c_rloop:
call i2c_wait
setb scl
nop
mov c,sda
rlc a
nop
clr scl
djnz r3,i2c_rloop
mov c,i2c_ack_out ; send Acknowledge-bit
mov sda,c
nop
setb scl
call i2c_wait
clr scl
nop
clr sda
pop 3
ret
i2c_wait: ; delay for I2C (CALL + RET -> 4us at 12MHz)
ret
;*********************************************************
; charcter font (5x8)
spalten: ; font ASCII-chars from 32(dec.) on
db 0,0,0,0,0 ; blank char
db 0,0,242,0,0 ; !
db 0,224,0,224,0 ; "
db 40,254,40,254,40 ; #
db 36,84,254,84,72 ; $
db 196,200,16,38,70 ; %
db 108,146,170,132,10 ; &
db 0,160,192,0,0 ; ï
db 0,56,68,130,0 ; (
db 0,130,68,56,0 ; )
db 40,16,124,16,40 ; *
db 16,16,124,16,16 ; +
db 0,5,6,0,0 ; ,
db 16,16,16,16,16 ; -
db 0,6,6,0,0 ; .
db 4,8,16,32,64 ; /
db 124,138,146,162,124; 0
db 0,66,254,2,0 ; 1
db 66,134,138,146,98 ; 2
db 132,130,162,226,156; 3
db 24,40,72,254,8 ; 4
db 228,162,162,162,156; 5
db 60,82,146,146,12 ; 6
db 128,142,144,160,192; 7
db 108,146,146,146,108; 8
db 96,146,146,148,120 ; 9
db 0,54,54,0,0 ; :
db 0,53,54,0,0 ; ;
db 16,40,68,130,0 ; <
db 40,40,40,40,40 ; =
db 0,130,68,40,16 ; >
db 64,128,138,144,96 ; ?
db 76,146,158,130,124 ; @
db 126,144,144,144,126; A
db 254,146,146,146,108; B
db 124,130,130,130,68 ; C
db 254,130,130,130,124; D
db 254,146,146,146,146; E
db 254,144,144,144,144; F
db 124,130,146,146,92 ; G
db 254,16,16,16,254 ; H
db 0,130,254,130,0 ; I
db 132,130,130,130,252; J
db 254,16,40,68,130 ; K
db 254,2,2,2,2 ; L
db 254,64,32,64,254 ; M
db 254,64,32,16,254 ; N
db 124,130,130,130,124; O
db 254,144,144,144,96 ; P
db 124,130,134,130,125; Q
db 254,144,152,148,98 ; R
db 100,146,146,146,76 ; S
db 128,128,254,128,128; T
db 252,2,2,2,252 ; U
db 248,4,2,4,248 ; V
db 254,4,8,4,254 ; W
db 198,40,16,40,198 ; X
db 192,32,30,32,192 ; Y
db 134,138,146,162,194; Z
db 0,254,130,130,0 ; [
db 64,32,16,8,4 ; \
db 0,130,130,254,0 ; ]
db 32,64,128,64,32 ; ^
db 2,2,2,2,2 ; _
db 0,128,64,32,0 ; `
db 4,42,42,42,30 ; a
db 254,18,34,34,28 ; b
db 28,34,34,34,34 ; c
db 28,34,34,18,254 ; d
db 28,42,42,42,24 ; e
db 16,126,144,128,64 ; f
db 24,37,37,37,62 ; g
db 254,16,32,32,30 ; h
db 0,34,190,2,0 ; i
db 4,2,34,188,0 ; j
db 254,8,20,34,0 ; k
db 0,130,254,2,0 ; l
db 62,32,24,32,30 ; m
db 62,16,32,32,30 ; n
db 28,34,34,34,28 ; o
db 63,36,36,36,24 ; p
db 24,36,36,36,63 ; q
db 62,16,32,32,16 ; r
db 18,42,42,42,4 ; s
db 32,254,34,2,4 ; t
db 60,2,2,4,62 ; u
db 56,4,2,4,56 ; v
db 60,2,12,2,60 ; w
db 34,20,8,20,34 ; x
db 48,10,10,10,60 ; y
db 34,38,42,50,34 ; z
db 0,16,108,130,0 ; {
db 0,0,254,0,0 ; |
db 0,130,108,16,0 ; }
db 16,32,16,8,16 ; ~
db 0,0,0,0,0 ; (ASCII 127 dec.)
db 4,170,42,170,30 ; „ (not standardized)
db 28,162,34,162,28 ; ”
db 28,66,2,66,28 ;
db 62,208,80,208,62 ; Ž
db 60,194,66,194,60 ; ™
db 60,130,2,130,60 ; š
db 127,144,146,146,108; á
;********************************************************
; Text to be displayed on the LED moving font.
; The number of chars must be defined as a 2-Byte-value as
; Highbyte/Lowbyte in "z_anz_rom".
z_anz_rom:
db 0h,70h ; number of chars stored in ROM
; (16-Bit as Highbyte/Lowbyte)
zeichen:
db 'World Of Electronics - Informationen rund um Elektronik:'
db ' http://www.online.de/home/woe'
db ' email: woe@topmail.de'
db ' ' ; 3 blank chars at the end as separation
; altogether 112 chars = 070h
END
**************************
;**********************************************************
;* LEDFONT.ASM V2.1 *
;* LED moving font *
;* Several MAX7219 are cascaded, modules consist of *
;* 8x8 LEDs; character font 5x8 *
;* Assembler program for 8051-compatible controller, *
;* e.g. AT89C51, quartz frequency 11,0592 MHz *
;* The following program controls up to 11 modules. *
;**********************************************************
;* World Of Electronics *
;* **broken link removed** *
;* woe@topmail.de *
;* (c) WOE, 1999 *
;**********************************************************
DIN equ p1.0 ; DIN at Port 1.0
CLCK equ p1.1 ; CLK at Port 1.1
LOAD equ p1.2 ; LOAD at Port 1.2
scl equ p3.5 ; SCL for I2C-Bus
sda equ p3.7 ; SDA for I2C-Bus
jumper_ser equ p1.6 ; Jumper for serial download
jumper_eep equ p3.2 ; Jumper for EEPROM-mode
jumper_baud equ p3.3 ; Jumper for serial baudrate
ser_wait equ p3.4 ; serial handshake
led equ p1.7 ; LED for serial download
MODULE equ 11 ; number of 8x8 LED modules (max. 11)
; Flags (in bit area, adr. 20h internal RAM)
i2c_ack_in equ 0
i2c_ack_out equ 1
z_abfrage equ 2
eep_mode equ 3
z_anz_h equ 21h ; number of characters
z_anz_l equ 22h ; (16 bit value)
zeichen_h equ 23h ; character counter
zeichen_l equ 24h ; (16 bit value)
sp_off_l equ 25h ; Offset for character font
sp_off_h equ 26h ; (16 bit value)
anfang:
setb i2c_ack_out
setb i2c_ack_in
call clear_disp
call ledout_ini ; Initialization
jb jumper_ser,lauf
jmp ser_load
lauf:
jb jumper_eep,rom_mode
setb eep_mode
call read_z_anz ; read number of chars out of EEPROM
jmp anz_ende
rom_mode:
clr eep_mode
call read_anz_rom ; read number of chars out of ROM
anz_ende:
mov r0,#40
clr a
clr_loop:
mov @r0,a ; clear memory cells 40...127 (internal RAM)
inc r0
cjne r0,#128,clr_loop
lauf_loop:
call ledout_ini
mov zeichen_h,#0 ; character counter HIGH
mov zeichen_l,#0 ; character counter LOW
clr z_abfrage
mov r5,#0 ; r5: column counter
jnb eep_mode,rom_dat
call read_eeprom
jmp read_end
rom_dat:
call read_rom
read_end:
spa:
jnb acc.7,z_ascii
call convert_char
jmp z_ok
z_ascii:
clr c
subb a,#32
jnc z_ok
clr a
z_ok:
mov b,#5
mul ab
mov sp_off_l,a ; Offset for column
mov sp_off_h,b ; (16 bit value)
wdh:
mov r1,#127
mov r0,#126
shift_ram:
mov a,@r0
mov @r1,a
dec r1
dec r0
cjne r1,#40,shift_ram
cjne r5,#5,sp_calc
mov 40,#0 ; LED-column on the right side
mov r5,#0
setb z_abfrage
inc zeichen_l
mov a,#0
cjne a,zeichen_l,x1
inc zeichen_h
x1:
jnb eep_mode,rom_dat2
call read_eeprom
jmp read_end2
rom_dat2:
call read_rom
read_end2:
spal:
jnb acc.7,z_ascii2
call convert_char
jmp z_ok2
z_ascii2:
clr c
subb a,#32
jnc z_ok2
mov a,#0
z_ok2:
mov b,#5
mul ab
mov sp_off_l,a
mov sp_off_h,b
jmp l1
sp_calc:
mov dptr,#spalten
mov a,sp_off_l
add a,dpl
jnc y1
inc dph
y1:
mov dpl,a
mov a,sp_off_h
add a,dph
mov dph,a
mov a,r5
movc a,@a+dptr
mov 40,a ; LED-column on the right side
inc r5
l1:
matrix:
mov r2,#8 ; 8 columns
mov r6,#47 ; left LED-column of the 8x8-module on the right
led_10:
mov b,#((MODULE-1)*8)
dispout:
mov a,r6
add a,b
mov r1,a
mov a,@r1
mov r3,a
call ledout
mov a,b
clr c
subb a,#8
mov b,a
jnc dispout
setb LOAD ; all MAX7219 store their data
clr LOAD
dec r6
djnz r2,led_10 ; all 8 columns of a module
call zeit ; delay
jnb z_abfrage,wdh_jump
clr z_abfrage
mov a,z_anz_l
cjne a,zeichen_l,wdh_jump
mov a,z_anz_h
cjne a,zeichen_h,wdh_jump
jmp lauf_loop
wdh_jump:
jmp wdh
ser_load:
jnb jumper_baud,b1200 ; sample jumper for baudrate
b9600:
mov th1, #0fdh ; 9600 Baud
mov tl1, #0fdh
jmp ser
b1200:
mov th1,#0e8h ; 1200 Baud
mov tl1,#0e8h
ser:
mov tmod, #20h
mov scon, #50h
setb tr1
mov a, sbuf
clr ri
clr led ; LED Download on
mov z_anz_h,#0
mov z_anz_l,#0
mov r7,#2 ; data in EEPROM starts at address 2
mov r6,#0a0h
clr ser_wait
wait_data:
jb p3.0,no_startbit
setb ser_wait
no_startbit:
jb ri,ri_ok
jmp wait_data
ser_wdh:
clr ser_wait
mov r4,#3
w3:
mov r3,#0
w2:
mov r2,#0
w1:
jb p3.0,no_start
setb ser_wait
no_start:
jb ri,ri_ok
djnz r2,w1
djnz r3,w2
djnz r4,w3
jmp ser_end
ri_ok:
mov a,sbuf
clr ri
setb ser_wait
setb led ; LED off
mov b,a
call i2c_start
mov a,r6 ; I2C-address EEPROM
call i2c_send
mov a,r7 ; address in EEPROM
call i2c_send
mov a,b ; data for EEPROM
call i2c_send
call i2c_stop
call wait_eeprom
inc r7
cjne r7,#0,s1
inc r6
inc r6
s1:
inc z_anz_l
mov a,z_anz_l
cjne a,#0,s2
inc z_anz_h
s2:
mov r5,z_anz_h
cjne r5,#7h,ser_wdh
cjne a,#0FEh,ser_wdh
ser_end:
call i2c_start
mov a,#0a0h
call i2c_send
mov a,#0
call i2c_send
mov a,z_anz_h
call i2c_send
call i2c_stop
call wait_eeprom
call i2c_start
mov a,#0a0h
call i2c_send
mov a,#1
call i2c_send
mov a,z_anz_l
call i2c_send
call i2c_stop
call wait_eeprom
setb ser_wait
blink:
cpl led
mov r7,#2
bl1:
mov r6,#0
bl2:
mov r5,#0
bl3:
djnz r5,bl3
djnz r6,bl2
djnz r7,bl1
jmp blink
read_eeprom: ; read actual character out of EEPROM
push 6
push 7
mov r6,zeichen_h
mov r7,zeichen_l
mov a,r7
add a,#2
jnc no_inc
inc r6
no_inc:
mov r7,a
mov a,r6
rl a
orl a,#0a0h
mov r6,a
call i2c_start
call i2c_send
mov a,r7
call i2c_send
call i2c_start
mov a,r6
inc a
call i2c_send
setb i2c_ack_out ; no ACK
call i2c_read
call i2c_stop
pop 7
pop 6
ret
read_rom: ; read actual character out of ROM
mov dptr,#zeichen
mov a,dpl
add a,zeichen_l
jnc no_inc_dph
inc dph
no_inc_dph:
mov dpl,a
mov a,dph
add a,zeichen_h
mov dph,a
clr a
movc a,@a+dptr
ret
read_z_anz: ; read number of chars out of EEPROM
call i2c_start
mov a,#0a0h
call i2c_send
mov a,#0
call i2c_send
call i2c_start
mov a,#0a1h
call i2c_send
clr i2c_ack_out
call i2c_read
mov z_anz_h,a
setb i2c_ack_out ; no ACK
call i2c_read
mov z_anz_l,a
call i2c_stop
ret
read_anz_rom: ; read number of chars out of ROM
mov dptr,#z_anz_rom
clr a
movc a,@a+dptr
mov z_anz_h,a
mov a,#1
movc a,@a+dptr
mov z_anz_l,a
ret
convert_char:
cjne a,#132,co1
mov a,#96 ; „
ret
co1:
cjne a,#148,co2
mov a,#97 ; ”
ret
co2:
cjne a,#129,co3
mov a,#98 ;
ret
co3:
cjne a,#142,co4
mov a,#99 ; Ž
ret
co4:
cjne a,#153,co5
mov a,#100 ; ™
ret
co5:
cjne a,#154,co6
mov a,#101 ; š
ret
co6:
cjne a,#225,co7
mov a,#102 ; á
ret
co7:
clr a ; otherwise blank character
ret
;********************************************************
; Initialization: (uses R1, R2, R3, Accu)
ledout_ini:
clr DIN
clr CLCK
clr LOAD
;Decode mode at digit 0-7 = normal:
mov r2,#09h ; Address of Decode Mode Register
mov r3,#0h ; no decode
mov r1,#MODULE
decode:
call ledout
djnz r1,decode ; all modules
setb LOAD
clr LOAD
;set intensity on maximum:
mov r2,#0Ah ; Address of Intensity Register
mov r3,#0Fh ; max. intensity
mov r1,#MODULE
intens:
call ledout
djnz r1,intens ; all modules
setb LOAD
clr LOAD
;set Scan Limit on 8 active displays:
mov r2,#0Bh ; Address of Scan Limit Register
mov r3,#07h ; 8 digits
mov r1,#MODULE
scanlim:
call ledout
djnz r1,scanlim ; all modules
setb LOAD
clr LOAD
;Display test mode = off:
mov r2,#0Fh ; Address of Display Test Register
mov r3,#0h ; normal operation
mov r1,#MODULE
distest:
call ledout
djnz r1,distest ; all modules
setb LOAD
clr LOAD
;disable Shutdown = switch on display:
mov r2,#0Ch ; Address of Shutdown Register
mov r3,#01h ; normal operation
mov r1,#MODULE
shutd:
call ledout
djnz r1,shutd ; all modules
setb LOAD
clr LOAD
ret
;*************************************************
; clear complete display
clear_disp:
push 1
push 2
push 3
clr DIN
clr CLCK
clr LOAD
mov r2,#8 ; 8 Digits
led_ini_10:
mov r3,#0 ; data = 0
mov r1,#MODULE
modul:
call ledout
djnz r1,modul ; all modules
setb LOAD
clr LOAD
djnz r2,led_ini_10
pop 3
pop 2
pop 1
ret
;*************************************************
; send data to MAX7219 (without LOAD impulse!)
; Parameters:
; R2 = Address byte for MAX7219
; R3 = Data byte for MAX7219
ledout: push acc
push 0
push 1
mov acc,r2
mov r1,#2 ;2x 8 bits
lo_5: mov r0,#8 ;ever 8 bits
lo_10: jb acc.7,lo_20
clr DIN ;send 0
jmp lo_30
lo_20: setb DIN ;send 1
lo_30: setb CLCK ;generate clock
clr CLCK
rl a ;next bit
djnz r0,lo_10 ;(8 times)
mov a,r3 ;Data byte in accu
djnz r1,lo_5 ;once again, but now with data byte
pop 1
pop 0
pop acc
ret
;********************************************************
; delay
zeit:
push acc
push b
mov b,#0eh ; start value of register B can be
z1: mov a,#0ffh ; increased for slower moving speed
z2: nop
nop
nop
nop
djnz acc,z2
djnz b,z1
pop b
pop acc
ret
wait_eeprom:
push 5
push 6
mov r6,#50
w_eep1:
mov r5,#100
w_eep2:
djnz r5,w_eep2
djnz r6,w_eep1
pop 6
pop 5
ret
i2c_start: ; I2C Start condition
setb sda
nop
setb scl
call i2c_wait
clr sda ; Data = 0 (Start)
nop
clr scl ; Clock = 0
ret
i2c_stop: ; I2C Stop condition
setb scl ; Clock = 1
nop
setb sda ; Data = 1 (Stop)
ret
i2c_send: ; send 1 data byte (Accu) via I2C
push 3
mov r3,#8
i2c_sloop:
rlc a
mov sda,c
nop
setb scl
call i2c_wait
clr scl
djnz r3,i2c_sloop
nop
setb sda
nop
setb scl
call i2c_wait
mov c,sda ; read Acknowledge-bit
mov i2c_ack_in,c
clr scl
nop
clr sda
pop 3
ret
i2c_read: ; receive 1 data byte via I2C (Accu)
push 3
mov r3,#8
clr a
setb sda
i2c_rloop:
call i2c_wait
setb scl
nop
mov c,sda
rlc a
nop
clr scl
djnz r3,i2c_rloop
mov c,i2c_ack_out ; send Acknowledge-bit
mov sda,c
nop
setb scl
call i2c_wait
clr scl
nop
clr sda
pop 3
ret
i2c_wait: ; delay for I2C (CALL + RET -> 4us at 12MHz)
ret
;*********************************************************
; charcter font (5x8)
spalten: ; font ASCII-chars from 32(dec.) on
db 0,0,0,0,0 ; blank char
db 0,0,242,0,0 ; !
db 0,224,0,224,0 ; "
db 40,254,40,254,40 ; #
db 36,84,254,84,72 ; $
db 196,200,16,38,70 ; %
db 108,146,170,132,10 ; &
db 0,160,192,0,0 ; ï
db 0,56,68,130,0 ; (
db 0,130,68,56,0 ; )
db 40,16,124,16,40 ; *
db 16,16,124,16,16 ; +
db 0,5,6,0,0 ; ,
db 16,16,16,16,16 ; -
db 0,6,6,0,0 ; .
db 4,8,16,32,64 ; /
db 124,138,146,162,124; 0
db 0,66,254,2,0 ; 1
db 66,134,138,146,98 ; 2
db 132,130,162,226,156; 3
db 24,40,72,254,8 ; 4
db 228,162,162,162,156; 5
db 60,82,146,146,12 ; 6
db 128,142,144,160,192; 7
db 108,146,146,146,108; 8
db 96,146,146,148,120 ; 9
db 0,54,54,0,0 ; :
db 0,53,54,0,0 ; ;
db 16,40,68,130,0 ; <
db 40,40,40,40,40 ; =
db 0,130,68,40,16 ; >
db 64,128,138,144,96 ; ?
db 76,146,158,130,124 ; @
db 126,144,144,144,126; A
db 254,146,146,146,108; B
db 124,130,130,130,68 ; C
db 254,130,130,130,124; D
db 254,146,146,146,146; E
db 254,144,144,144,144; F
db 124,130,146,146,92 ; G
db 254,16,16,16,254 ; H
db 0,130,254,130,0 ; I
db 132,130,130,130,252; J
db 254,16,40,68,130 ; K
db 254,2,2,2,2 ; L
db 254,64,32,64,254 ; M
db 254,64,32,16,254 ; N
db 124,130,130,130,124; O
db 254,144,144,144,96 ; P
db 124,130,134,130,125; Q
db 254,144,152,148,98 ; R
db 100,146,146,146,76 ; S
db 128,128,254,128,128; T
db 252,2,2,2,252 ; U
db 248,4,2,4,248 ; V
db 254,4,8,4,254 ; W
db 198,40,16,40,198 ; X
db 192,32,30,32,192 ; Y
db 134,138,146,162,194; Z
db 0,254,130,130,0 ; [
db 64,32,16,8,4 ; \
db 0,130,130,254,0 ; ]
db 32,64,128,64,32 ; ^
db 2,2,2,2,2 ; _
db 0,128,64,32,0 ; `
db 4,42,42,42,30 ; a
db 254,18,34,34,28 ; b
db 28,34,34,34,34 ; c
db 28,34,34,18,254 ; d
db 28,42,42,42,24 ; e
db 16,126,144,128,64 ; f
db 24,37,37,37,62 ; g
db 254,16,32,32,30 ; h
db 0,34,190,2,0 ; i
db 4,2,34,188,0 ; j
db 254,8,20,34,0 ; k
db 0,130,254,2,0 ; l
db 62,32,24,32,30 ; m
db 62,16,32,32,30 ; n
db 28,34,34,34,28 ; o
db 63,36,36,36,24 ; p
db 24,36,36,36,63 ; q
db 62,16,32,32,16 ; r
db 18,42,42,42,4 ; s
db 32,254,34,2,4 ; t
db 60,2,2,4,62 ; u
db 56,4,2,4,56 ; v
db 60,2,12,2,60 ; w
db 34,20,8,20,34 ; x
db 48,10,10,10,60 ; y
db 34,38,42,50,34 ; z
db 0,16,108,130,0 ; {
db 0,0,254,0,0 ; |
db 0,130,108,16,0 ; }
db 16,32,16,8,16 ; ~
db 0,0,0,0,0 ; (ASCII 127 dec.)
db 4,170,42,170,30 ; „ (not standardized)
db 28,162,34,162,28 ; ”
db 28,66,2,66,28 ;
db 62,208,80,208,62 ; Ž
db 60,194,66,194,60 ; ™
db 60,130,2,130,60 ; š
db 127,144,146,146,108; á
;********************************************************
; Text to be displayed on the LED moving font.
; The number of chars must be defined as a 2-Byte-value as
; Highbyte/Lowbyte in "z_anz_rom".
z_anz_rom:
db 0h,70h ; number of chars stored in ROM
; (16-Bit as Highbyte/Lowbyte)
zeichen:
db 'World Of Electronics - Informationen rund um Elektronik:'
db ' http://www.online.de/home/woe'
db ' email: woe@topmail.de'
db ' ' ; 3 blank chars at the end as separation
; altogether 112 chars = 070h
END