|
|
Elektronika.lt portalo forumas
Jūs esate neprisijungęs lankytojas. Norint dalyvauti diskusijose, būtina užsiregistruoti ir prisijungti prie forumo.
Prisijungę galėsite kurti naujas temas, atsakyti į kitų užduotus klausimus, balsuoti forumo apklausose.
Administracija pasilieka teisę pašalinti pasisakymus bei dalyvius,
kurie nesilaiko forumo taisyklių.
Pastebėjus nusižengimus, prašome pranešti.
Dabar yra 2025 01 29, 20:46. Visos datos yra GMT + 2 valandos.
|
|
|
|
Forumas » Mikrovaldikliai » matrix 8x8 ASM programa
|
Jūs negalite rašyti naujų pranešimų į šį forumą Jūs negalite atsakinėti į pranešimus šiame forume Jūs negalite redaguoti savo pranešimų šiame forume Jūs negalite ištrinti savo pranešimų šiame forume Jūs negalite dalyvauti apklausose šiame forume
|
|
|
|
|
|
matrix 8x8 ASM programa |
Parašytas: 2011 01 08, 22:20 |
|
|
|
pasirasiau paprasta programa ASM kalba, su kurios pagalba tiesiog matrix led 8x8 diodai sviecia stulpeliais.
Pvz.:
Kodas: |
LIST P=16F876
#include <p16F876.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ORG 0x2100
DE 0x00
ORG 0
cblock 0x20
d1
d2
d3
endc
goto start
Delay
;999990 cycles
movlw 0x07
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
;4 cycles (including call)
return
loop:
movlw b'00000111'
movwf PORTA
movlw b'11110010'
movwf PORTB
movlw b'11111111'
movwf PORTC
call Delay
call Delay
call Delay
goto loop
start:
bsf STATUS,RP0 ; select register page 1
movlw 0 ; put 0 into W
movwf TRISC ; set portC all output
clrf TRISA
clrf TRISB
bsf STATUS,RP1 ; select Page 2,
bcf STATUS,RP0 ; by setting RP1 in Status register and clearing RP0
clrf PORTC ; select Digital I/O on port C
bcf STATUS,RP1 ; back to Register Page 0
goto loop
end |
Bet noriu "sustresnes" programos su kuria galeciau atvaizduoti begancius zodzius per ekrana. Pradziai pameginau padaryti, kad uzsidegtu pora stulpeliu bet su skirtingose vietose deganciais diodais. Taciau gavosi kazkoks keistas blyksejimas, neiseina padaryti, kad ilgiau sviestu. Gal kas zinosit kas negerai...
Programos kodas:
Kodas: |
LIST P=16F876
#include <p16F876.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ORG 0x2100
DE 0x00
ORG 0
cblock 0x20
Delay1 ; delay loop 1
Delay2 ; delay loop 2
Delay3 ; delay loop 3
TimeDelay ; time delay x 0.001 s
EndCount ; used to tell PIC the end of the table is reached
Counter ; used as table counter
Line1 ; Line 1
Line2 ; Line 2
Line3 ; Line 3
Line4 ; Line 4
Line5 ; Line 5
sad
Line6 ; Line 6
Line7 ; Line 7
Line8 ; Line 8
Layer4 ; brightness, and time
Brightness ; LED brightness
Time ; time for each pattern to stay
Temp ; temp register
d1
d2
d3
endc
goto start
Delay
;999990 cycles
movlw 0x17
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
;4 cycles (including call)
return
loop:
movlw b'00000001'
movwf Line1
movlw b'11110010'
movwf Line2
call output
call Delay
movlw b'11100000'
movwf Line1
movlw b'10101010'
movwf Line2
call output
call Delay
goto loop
start:
bsf STATUS,RP0 ; select register page 1
movlw 0 ; put 0 into W
movwf TRISC ; set portC all output
clrf TRISA
clrf TRISB
bsf STATUS,RP1 ; select Page 2,
bcf STATUS,RP0 ; by setting RP1 in Status register and clearing RP0
clrf PORTC ; select Digital I/O on port C
bcf STATUS,RP1 ; back to Register Page 0
goto loop
output:
movfw Layer4
andlw b'00000001'
movwf Time
incf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
clrf PORTB ; clear port B
movfw Line1 ; move layer1 to W
movwf PORTC ; put W onto PortC
bsf PORTB,4 ; turn on layer 1 buy outputing bit 5 of PortB
movfw Brightness ; put brightness into W
call Delayy ; call the delay
bcf PORTB,4 ; turn off layer 1
movfw Brightness ; put Brightness into W
sublw 4 ; sub W from 4
btfss STATUS,Z ; skip if the zero flag is set
call Delayy ; call the delay
decfsz Time
clrf PORTB ; clear port B
movfw Line2 ; move Line2 to W
movwf PORTC ; put W onto PortC
bsf PORTB,5 ; turn on layer 2 buy outputing bit 6 of PortB
movfw Brightness ; put brightness into W
call Delayy ; call the delay
bcf PORTB,5 ; turn off layer 2
movfw Brightness ; put Brightness into W
sublw 4 ; sub W from 4
btfss STATUS,Z ; skip if the zero flag is set
call Delayy ; call the delay
decfsz Time
decfsz Time ; decrement the Time regiester
return
Delayy:
movwf Delay3 ; put W into Delay 3
Loop1:
; After Delay2 decreses to 0, it is reset to..
movlw 0x1 ; put 1 into W
movwf Delay2 ; put W into Delay2
Loop2:
; After Delay1 decreses to 0, it is reset to E9h
movlw 0x1D ; put 80 into W
movwf Delay1 ; put W into Delay1
Loop3:
decfsz Delay1 ; decrement Delay1
goto Loop3 ; jump back to Loop3
decfsz Delay2 ; decrement Delay2
goto Loop2 ; jump back to Loop2
decfsz Delay3 ; decrement Delay3
goto Loop1 ; jump back to Loop1
return
end
|
|
|
|
|
|
|
|
matrix 8x8 ASM programa |
Parašytas: 2011 01 10, 12:23 |
|
|
|
Kažkada dariau su pic16f84
Kodas: |
;=====================================================
; * PIC16F84 4MHz begantis tekstas *
;=====================================================
LIST p=16F84
#include <p16f84a.inc>
__config _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF
;=====================================================
; * kintamieji *
;=====================================================
sk0 equ 20h
sk1 equ 21h
sk2 equ 22h
sk3 equ 23h
temp equ 24h
count equ 25h
speed equ 26h
count2 equ 27h
speed2 equ 28h
disp equ 30h
disp2 equ 38h
;=====================================================
; * org 0x00 *
;=====================================================
org 0x00
goto pic_reset
;=====================================================
; * raides *
; * visos raides aprasomos programos pradzioje
; * maks. raidziu skaicius 20 (jei raide uzima 8x8
; * kaip pvz.: raide_mm) nes naudojami tik 8
; * bitai PC (PCL)
;=====================================================
raide:
movwf PCL
raide_a:
movlw .5
movwf count2
movf PCL,W
call load_sym
retlw b'00000000'
retlw b'01111110'
retlw b'10010000'
retlw b'10010000'
retlw b'01111110'
;**
raide_e:
movlw .5
movwf count2
movf PCL,W
call load_sym
retlw b'00000000'
retlw b'11111110'
retlw b'10010010'
retlw b'10010010'
retlw b'10000010'
;**
raide_s:
movlw .5
movwf count2
movf PCL,W
call load_sym
retlw b'00000000'
retlw b'01100100'
retlw b'10010010'
retlw b'10010010'
retlw b'01001100'
;**
raide_j:
movlw .5
movwf count2
movf PCL,W
call load_sym
retlw b'00000000'
retlw b'10000100'
retlw b'10000010'
retlw b'10000010'
retlw b'11111100'
;**
raide_k:
movlw .5
movwf count2
movf PCL,W
call load_sym
retlw b'00000000'
retlw b'11111110'
retlw b'00010000'
retlw b'00101000'
retlw b'11000110'
raide_t:
movlw .4
movwf count2
movf PCL,W
call load_sym
retlw b'00000000'
retlw b'10000000'
retlw b'11111110'
retlw b'10000000'
raide_u:
movlw .5
movwf count2
movf PCL,W
call load_sym
retlw b'00000000'
retlw b'11111100'
retlw b'00000010'
retlw b'00000010'
retlw b'11111100'
;**
raide_n:
movlw .5
movwf count2
movf PCL,W
call load_sym
retlw b'00000000'
retlw b'11111110'
retlw b'00100000'
retlw b'00010000'
retlw b'11111110'
;**
raide_taskas:
movlw .3
movwf count2
movf PCL,W
call load_sym
retlw b'00000000'
retlw b'00000110'
retlw b'00000110'
raide_clr:
movlw .8
movwf count2
movf PCL,W
call load_sym
retlw b'00000000'
retlw b'00000000'
retlw b'00000000'
retlw b'00000000'
retlw b'00000000'
retlw b'00000000'
retlw b'00000000'
retlw b'00000000'
;=====================================================
; * begantis tekstas "KAJUS.NET " *
;=====================================================
loop:
call raide_k
call perstumti
call raide_a
call perstumti
call raide_j
call perstumti
call raide_u
call perstumti
call raide_s
call perstumti
call raide_taskas
call perstumti
call raide_n
call perstumti
call raide_e
call perstumti
call raide_t
call perstumti
call raide_clr
call perstumti
goto loop
;=====================================================
; * uzkrauti simboli i display ram - 0x30..0x37 *
;=====================================================
load_sym:
movwf temp
movlw .1
addwf temp,F ;PCL+1
movlw disp2
movwf FSR
clrf count
load_loop:
movf temp, W
addwf count, W
call raide
movwf INDF
incf count, F
movf count2,W
subwf count, W
btfsc STATUS,Z
return
incf FSR, F
goto load_loop
;=====================================================
; * atvaizduoti simboli *
;=====================================================
display:
movf speed, W
movwf speed2
dispp:
movlw disp
movwf FSR
clrf count
disp_loop:
movf INDF, W
movwf PORTB
call pauze1ms
clrf PORTB
incf count
movlw .8
subwf count, W
btfsc STATUS,Z
goto _rs
_cl:
call _clock
incf FSR
goto disp_loop
_rs:
call _reset
decfsz speed2
goto dispp
return
;=====================================================
; * perstumti simboli *
;=====================================================
perstumti:
; movlw .8
; movwf count2
p0_loop:
call display
movlw .15
movwf count
movlw disp+1
movwf FSR
p_loop:
movf INDF, W
movwf temp
clrf INDF
decf FSR
movf temp, W
movwf INDF
incf FSR
incf FSR
decfsz count
goto p_loop
decfsz count2
goto p0_loop
return
;=====================================================
; * cd4017 valdymas *
;=====================================================
_reset:
bsf PORTA,1
nop
nop
nop
bcf PORTA,1
nop
nop
nop
return
_clock:
bsf PORTA,0
nop
nop
nop
bcf PORTA,0
nop
nop
nop
return
;=====================================================
; * pauzes *
;=====================================================
pauze1ms:
movlw .75
movwf sk0
movlw .2
movwf sk1
decfsz sk0
goto $-1
decfsz sk1
goto $-3
return
pauze200ms:
movlw .0
movwf sk0
movlw .0
movwf sk1
movlw .6
movwf sk2
decfsz sk0
goto $-1
decfsz sk1
goto $-3
decfsz sk2
goto $-5
return
;=====================================================
; * programos pradzia *
;=====================================================
pic_reset:
clrf PORTB
clrf PORTA
bsf STATUS,5
clrf TRISB
movlw b'01100'
movwf TRISA
bcf STATUS,5
;**
movlw .15
movwf speed
call _reset
goto loop
end
|
schemą įdėsiu vėliau - jei dar rasiu. |
|
|
|
|
|
|
matrix 8x8 ASM programa |
Parašytas: 2011 01 10, 19:16 |
|
|
|
Dekui uz nuoroda. Dar turiu klausima is sio kodo:
Kodas: |
output:
clrf PORTB ; clear port B
movfw Line1 ; move layer1 to W
movwf PORTC ; put W onto PortC
bsf PORTB,4 ; turn on layer 1 buy outputing bit 5 of PortB
movfw Brightness ; put brightness into W
bcf PORTB,4
movfw Line2
movwf PORTC
bsf PORTB,5
movfw Brightness
call Delay ; call the delay
bcf PORTB,5 ; turn off layer 1 |
virsuje pateiktas kodas iskarto atvaizduoja Line2, praleisdamas Line1. kaip pakeisti koda, kad Line1 ir Line2 galetu atvaizduoti vienu metu? |
|
|
|
|
|
matrix 8x8 ASM programa |
Parašytas: 2011 01 11, 10:30 |
|
|
|
Kodas: |
loop:
call output
goto loop
output:
clrf PORTB
movfw Line1
movwf PORTC
bsf PORTB,4
call Delay
movfw Brightness ;nereikalingas niekur nenaudojamas
bcf PORTB,4
movfw Line2
movwf PORTC
bsf PORTB,5
call Delay
movfw Brightness
bcf PORTB,5
return
|
|
|
|
|
|
|
|
matrix 8x8 ASM programa |
Parašytas: 2011 01 11, 13:26 |
|
|
|
Pakoregavau internete rasta programa ir pritaikiau savo pic16f876 mokroprocesoriui. programa veikia gerai, tik toje programoje yra Brightness nustatymai, del kuriu speju mano matrix displejus silpnokai sviecia. Kuo viename stulpelyje uzsidega daugiau diodu, tuo jie silpniau sviecia. Kodas:
Kodas: |
LIST P=16F876
#include <p16F876.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ORG 0x2100
DE 0x00
ORG 0
cblock 0x20
Delay1
Delay2
Delay3
TimeDelay
EndCount
Counter
Line1
Line2
Line3
Line4
Line5
sad
Line6
Line7
Line8
Layer4
Brightness
Time
Temp
endc
goto Start
Start:
bsf STATUS,RP0
movlw 0
movwf TRISC
movwf TRISA
movlw b'00000001'
movwf TRISB
bsf STATUS,RP1
bcf STATUS,RP0
bcf STATUS,RP1
bcf EndCount,0
clrf Counter
clrf PORTB
snaige:
movlw b'10000001'
movwf Line1
movlw b'01000010'
movwf Line2
movlw b'00100100'
movwf Line3
movlw b'00011000'
movwf Line4
movwf Line5
movlw b'00100100'
movwf Line6
movlw b'01000010'
movwf Line7
movlw b'10000001'
movwf Line8
movlw b'11100111'
movwf Layer4
call Output
;snaiges kodas ilgas, tai ikeliau tik pvz.
goto snaige
Output:
movfw Layer4
movlw b'00000101'
movwf Brightness
bcf STATUS,C
rrf Brightness,1
incf Brightness,1
movfw Layer4
andlw b'00000001'
movwf Time
incf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
Output2:
clrf PORTA
movfw Line1
movwf PORTC
bsf PORTB,4
movfw Brightness
call Delay
bcf PORTB,4
movfw Brightness
sublw 4
btfss STATUS,Z
call Delay
clrf PORTB
movfw Line2
movwf PORTC
bsf PORTB,5
movfw Brightness
call Delay
bcf PORTB,5
movfw Brightness
sublw 4
btfss STATUS,Z
call Delay
clrf PORTB
movfw Line3
movwf PORTC
bsf PORTB,6
movfw Brightness
call Delay
bcf PORTB,6
movfw Brightness
sublw 4
btfss STATUS,Z
call Delay
clrf PORTB
movfw Line4
movwf PORTC
bsf PORTB,7
movfw Brightness
call Delay
bcf PORTB,7
movfw Brightness
sublw 4
btfss STATUS,Z
call Delay
clrf PORTB
clrf PORTA
movfw Line5
movwf PORTC
bsf PORTA,0
movfw Brightness
call Delay
bcf PORTA,0
movfw Brightness
sublw 4
btfss STATUS,Z
call Delay
clrf PORTA
movfw Line6
movwf PORTC
bsf PORTA,1
movfw Brightness
call Delay
bcf PORTA,1
movfw Brightness
sublw 4
btfss STATUS,Z
call Delay
decfsz Time
clrf PORTA
movfw Line7
movwf PORTC
bsf PORTA,2
movfw Brightness
call Delay
bcf PORTA,2
movfw Brightness
sublw 4
btfss STATUS,Z
call Delay
clrf PORTA
movfw Line8
movwf PORTC
bsf PORTB,1
movfw Brightness
call Delay
bcf PORTB,1
movfw Brightness
sublw 4
btfss STATUS,Z
call Delay
decfsz Time
goto Output2
return
Delay:
movwf Delay3
Loop1:
movlw 0x1
movwf Delay2
Loop2:
movlw 0x1D
movwf Delay1
Loop3:
decfsz Delay1
goto Loop3
decfsz Delay2
goto Loop2
decfsz Delay3
goto Loop1
return
tikrina
BTFSS PORTB,0
GOTO LINK
nop
return
end |
kaip suprantu sviesumui reguliuoti skirti parametrai:
;-----------------------------------
movlw b'11100111'
movwf Layer4
;-----------------------------------
ir
;-----------------------------------
Output:
movfw Layer4
movlw b'00000101'
movwf Brightness
bcf STATUS,C
rrf Brightness,1
incf Brightness,1
;-----------------------------------
Visaip bandziau keitalioti siuos parametrus (panaikinus Brightness visai nebesviecia), taciau gaunasi tamsiau ar sviesiau, taciau vistiek stulpeliuose kur sviecia daugiau diodu, jie sviecia zymiai blankiau...
Beje mano matrix 8x8 displejus katodinis. bet turbut tai reiksmes neturi..
negi ner kas suprastu? :/ |
|
|
|
|
|
|
|
|
|
|
Google paieška forume |
|
|
Naujos temos forume |
|
|
FS25 Tractors
Farming Simulator 25 Mods,
FS25 Maps,
FS25 Trucks |
|
ETS2 Mods
ETS2 Trucks,
ETS2 Bus,
Euro Truck Simulator 2 Mods
|
|
FS22 Tractors
Farming Simulator 22 Mods,
FS22 Maps,
FS25 Mods |
|
VAT calculator
VAT number check,
What is VAT,
How much is VAT |
|
LEGO
Mänguköök,
mudelautod,
nukuvanker |
|
Thermal monocular
Thermal vision camera,
Night vision ar scope,
Night vision spotting scope |
|
FS25 Mods
FS25 Harvesters,
FS25 Tractors Mods,
FS25 Maps Mods |
|
Dantų protezavimas
All on 4 implantai,
Endodontija mikroskopu,
Dantų implantacija |
|
FS25 Mods
FS25 Maps,
FS25 Cheats,
FS25 Install Mods |
|
GTA 6 Weapons
GTA 6 Characters,
GTA 6 Map,
GTA 6 Vehicles |
|
FS25 Mods
Farming Simulator 25 Mods,
FS25 Maps |
|
ATS Trailers
American Truck Simulator Mods,
ATS Trucks,
ATS Maps |
|
|
|