📄 f_3.asm
字号:
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
;----------------------------------------------------
;
;This subroutine is used to contorll PWM output time
;
define_time: cpi r26,-3
brne t_60
ldi r24,$01
ret
t_60: cpi r26,-2
brne t_90
ldi r24,$02
ret
t_90: cpi r26,-1
brne t_120
ldi r24,$03
ret
t_120: cpi r26,0
brne t_150
ldi r24,$04
ret
t_150: cpi r26,1
brne t_180
ldi r24,$05
ret
t_180: cpi r26,2
brne t_210
ldi r24,$06
ret
t_210: cpi r26,3
brne t_240
ldi r24,$07
ret
t_240: cpi r26,4
brne t_270
ldi r24,$08
ret
t_270: cpi r26,5
brne t_300
ldi r24,$09
ret
t_300: cpi r26,6
brne t_330
ldi r24,$0a
ret
t_330: cpi r26,7
brne t_360
ldi r24,$0b
ret
t_360: cpi r26,8
brne t_390
ldi r24,$0c
ret
t_390: cpi r26,9
brne t_420
ldi r24,$0d
ret
t_420: cpi r26,10
brne t_450
ldi r24,$0e
ret
t_450: cpi r26,11
brne t_480
ldi r24,$0e
ret
t_480: cpi r26,12
brne define_time
ldi r24,$0f
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
pwm_output: sbi DDRB,1 ;set PB.1 output mode
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
pwm: out TCCR1B,r7 ;Timer/Count 1 start to work
ldi r17,$00
out OCR1H,r17
out OCR1L,r8
mov r25,r27
ldi r17,$05
add r25,r17
pwm_width:rcall delay2
dec r25
brne pwm_width
inc r8
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -