📄 f6.asm
字号:
;-------------------display PC.3 second byte of time value
rcall b4_d0
ret
;-------------------- ; PC.4 display "0"
time_120: cpi r26,0
brne time_150
;----------------------
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 ,$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_150: cpi r26,1
brne time_180
;----------------------
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: cpi r26,12
breq led
rjmp t_leddisp
;----------------------
led: 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: wdr
wdr
ldi r18,-3
ldi r19,1
cp_time: cp r26,r18
breq equ
inc r18
inc r19
cpi r18,13
breq define_time
rjmp cp_time
equ: mov r24,r19
ret
;------------------------------------------------------
m_leddisp: wdr
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,0b10000011
out TCCR1A,r17 ; COM11=1,COM10=0,PWM11=1,PWM10=1 in TCCR1A
; PWM frequency is ftck1/2046 ,10 byte PWM
ldi r17,$00
out OCR1H,r17
out OCR1L,r8
out TCNT1H,r17
out TCNT1L,r17
ldi r17,0b00000001
out TCCR1B,r17 ;Timer/Count 1 start to work ,ftck1=fosc=8MHz
mov r25,r27
ldi r17,$05
add r25,r17
mov r17,r8
push r17
pwm_width:wdr
rcall delay2
dec r25
brne pwm_width
pop r17
brts down
cpi r17,30 ;controll high low level ratio<30/1023(<3%)
; copare value/top value 10 byte
; PWM PWM frenquency is ftck1/2046=8MHZ/2046=3.91KHz
brlo go_on
down: set ;set down_count flag
dec r8
breq go_on
rjmp back
go_on: clt ;set up_count flag
inc r8
back: clr r14
out TCCR1B,r14 ;Timer/Counter 1 stop working
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -