Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;-------------------------------------------------------------------
- ; Created by: Oslejsek Stepan A3
- ; Uloha 9 - dynamicky displej
- ; s casovacem
- ; Date: 11.1.2019
- ;-------------------------------------------------------------------
- .NOLIST
- .INCLUDE "m128def.inc"
- .LIST
- .CSEG
- .DEF tcycles = R16
- .DEF parameter = R17
- .DEF null = R18
- .DEF two = R19
- .DEF position = R22
- .DEF number = R23
- .DEF value = R24
- .DEF pcycles = R25
- .MACRO Timer ;timer macro
- LDI tcycles,@0
- LDI parameter,@1
- OUT TCCR2,parameter
- LDI parameter,@2
- OUT OCR2,parameter
- LDI two,2
- @3:
- IN null,TIFR
- CALL TIMER1ms ;calling timer for 1ms
- CP null,two
- BRNE @3
- OUT TIFR,two
- DEC tcycles
- BRNE @3
- RET
- .ENDMACRO
- .MACRO Program ;program macro
- Init1: ;first init
- CALL SETTINGS1
- LD pcycles,Y
- LDI position,0
- LDI number,8
- Fill: ;filling register X with values from table CODE
- LPM value,Z+
- ST X+,value
- DEC pcycles
- BRNE Fill
- Init2: ;second init
- CALL SETTINGS1
- LD pcycles,Y+ ;here is post increment, because I don't need to increment pcycles
- Lightup: ;light up segments on display
- LD value,X+ ;load value from X, post increment
- OUT PORTB,value ;send value to portb
- OUT PORTD,position ;send position to portd
- INC position ;increment position
- CALL @0 ;call timer 200/500 ms
- DEC pcycles ;repeat
- BRNE Lightup
- LD pcycles,Y
- CALL SETTINGS1
- DEC number
- BRNE Fill
- OUT PORTB,null ;turn off display
- .ENDMACRO
- LDI R20,low(RAMEND) ;init
- OUT SPL,R20
- LDI R20,high(RAMEND)
- OUT SPH,R20
- LDI R20,0xFF
- OUT DDRB,R20
- OUT DDRD,R20
- RJMP Main
- Main: ;whole program
- CALL SETTINGS2
- LDI pcycles,8
- Main1:
- LPM two,Z+
- ST Y+,two
- DEC pcycles
- BRNE Main1
- Program TIMER200
- CALL SETTINGS2
- Program TIMER500
- RJMP Main
- SETTINGS1: ;set address for register X + code
- LDI XL,0x20
- LDI XH,0x01
- LDI ZL,low(CODE*2)
- LDI ZH,high(CODE*2)
- RET
- SETTINGS2: ;set address for register Y + cycles
- LDI YL,0x00
- LDI YH,0x01
- LDI ZL,low(CYCLES*2)
- LDI ZH,high(CYCLES*2)
- RET
- TIMER200: ;timer for "200ms"
- Timer 50,0b00001110,188,TIMER200
- RET
- TIMER500: ;timer for "500ms"
- Timer 100,0b00001110,250,TIMER500
- RET
- TIMER1ms: ;timer 1ms for dynamic display
- LDI R20, 21
- LDI R21, 199
- L1:
- DEC R21
- BRNE L1
- DEC R20
- BRNE L1
- RET
- CYCLES: ;numbers of cycles
- .DB 1,2,3,4
- .DB 5,6,7,8
- CODE: ;codes for display
- .DB 0b11010111,0b11010111
- .DB 0b11010111,0b11010111
- .DB 0b11010111,0b11010111
- .DB 0b11010111,0b11010111
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement