📄 final_0.asm
字号:
;----------------------
ldi r20,$06
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; ---------------------display PC.2 first byte of time value
ldi r20 ,$6d
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0"
time_180: cpi r26,2
brne time_210
;----------------------
ldi r20,$06
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; ---------------------display PC.2 first byte of time value
ldi r20 ,$7f
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0"
time_210: cpi r26,3
brne time_240
;----------------------
ldi r20,$5b
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; ---------------------display PC.2 first byte of time value
ldi r20 ,$06
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0"
time_240: cpi r26,4
brne time_270
;----------------------
ldi r20,$5b
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; ---------------------display PC.2 first byte of time value
ldi r20 ,$66
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0"
time_270: cpi r26,5
brne time_300
;----------------------
ldi r20,$5b
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; --------------------display PC.2 first byte of time value
ldi r20 ,$07
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0"
time_300: cpi r26,6
brne time_330
;----------------------
ldi r20,$4f
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; --------------------display PC.2 first byte of time value
ldi r20 ,$3f
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0"
time_330: cpi r26,7
brne time_360
;----------------------
ldi r20,$4f
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; --------------------display PC.2 first byte of time value
ldi r20 ,$4f
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0
time_360: cpi r26,8
brne time_390
;----------------------
ldi r20,$4f
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; --------------------display PC.2 first byte of time value
ldi r20 ,$7d
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0
time_390: cpi r26,9
brne time_420
;----------------------
ldi r20,$4f
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; --------------------display PC.2 first byte of time value
ldi r20 ,$6f
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0
time_420: cpi r26,10
brne time_450
;----------------------
ldi r20,$66
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; --------------------display PC.2 first byte of time value
ldi r20 ,$5b
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0
time_450: cpi r26,11
brne time_480
;----------------------
ldi r20,$66
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; --------------------display PC.2 first byte of time value
ldi r20 ,$6d
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0
time_480: nop
;----------------------
ldi r20,$66
out SPDR , r20
ldi r17,0b0000100 ; display byte PC.2
out PORTC,r17
rcall delay
rcall turn_off
; --------------------display PC.2 first byte of time value
ldi r20 ,$7f
out SPDR , r20
ldi r17,0b00001000 ; display byte PC.3
out PORTC,r17
rcall delay
rcall turn_off
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0
b4_d0: ldi r20,$3f
out SPDR , r20
ldi r17,0b00010000
out PORTC,r17
rcall delay
rcall turn_off
ret
turn_off: ser r16
out DDRC,r16
ldi r17,0b0000000
out PORTC,r17
ret
;------------------------------------------------------
m_leddisp: rcall flash_ram
rcall turn_off
ldi r17,$05
add r27,r17
mov r20,r27 ;rcall flash_ram
ldi YL,$60
ldi YH,$00
add YL,r20 ; r20 is content of display word
ld r20,Y ;PC.0 display magnetic field trength
out SPDR , r20
ldi r17,0b00000001 ; display byte PC.0
out PORTC,r17 ;PC.0 output 1 ,
rcall delay
rcall turn_off
ldi r20,$3f ; PC.1 display "0"
out SPDR , r20
ldi r17,0b00000010
out PORTC,r17
rcall delay
rcall turn_off
subi r27,$05
ret
flash_ram: ldi YL,$60
ldi YH,$00 ;RAM begin address
ldi ZL ,low(seg_code*2) ; load Z register low byte
ldi ZH ,high(seg_code*2); load Z register high byte
ldi r18,$10 ;flash data block size
load_flash:lpm
st Y+,r0
adiw ZL,1
dec r18
brne load_flash
ret
.org $0700
seg_code:.db $3f,$06,$5b,$4f,$66,$6d,$7d,$07
.db $7f,$6f,$77,$7c,$39,$5e,$79,$71
m_min: ret
t_add: ret
t_min: ret
pwm_output: sbi DDRB,1 ;set PB.1 output mode
; ldi r17,$00
; out OCR1H,r17
; ldi r17,$0ff
; out OCR1L,R17 ; define compare value
ldi r17,0b11000001
out TCCR1A,r17 ; COM11=1,COM10=1,PWM11=1,PWM10=0 in TCCR1A
; PWM frequency is fosc/510 ,8 byte PWM
ldi r17,0b00000001
mov r7,r17
; mov r8,r7
pwm: out TCCR1B,r7 ;Timer/Count 1 start to work
ldi r17,$00
out OCR1H,r17
out OCR1L,r8
rcall delay2
inc r8
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -