共3条
1/1 1 跳转至页
LPM,FF,LPM,51,MOVC 为什么我用LPM读表格数据总是返回FF?LPM是不是和51中的MOVC同?
问
.include "m8def.inc"
.def u_sr =r15 ;Status-register storage
.def temp =r16 ; Define temporary variable
.def TIME_H =r17 ; Define timer variable high 8 bits
.def TIME_L =r18 ; Define timer variable low 8 bits
.cseg
.org $0000
rjmp RESET ;Reset handle
.org OVF0addr
rjmp tim0_ovf ;Timer0 overflow handler
tim0_ovf:
reti
RESET: ldi temp,low(RAMEND)
out SPL,temp ; Set stack pointer to last internal RAM location
ldi temp,high(RAMEND)
out SPH,temp
ldi temp,0
out DDRC,temp
sbi DDRB,DDB5 ; except PD4 -> output with 1's
ldi temp,1<<TOIE0 ;Set bit 1 in u_tmp
out TIFR,temp ; to clear T/C0 overflow flag
out TIMSK,temp ; and enable T/C0 overflow interrupt
out TCNT0,temp ;Set timer reload-value (1 bit)
sei
loop:
in temp,PINC
lsl temp
ldi ZH,0x04 ; Load high part of byte address into ZH
ldi ZL,0x00 ; Load low part of byte address into ZL
;ldi ZH,high(2*table) ; Load high part of byte address into ZH
;ldi ZL,low(2*table) ; Load low part of byte address into ZL
lpm
mov TIME_H,r0
inc ZL
lpm
mov TIME_L,r0
rjmp loop
.eseg
.org 0x400
;table:
.db 89 ;'Y'
.db 111 ;'o'
.db 117 ;'u'
.db 32 ;' '
.db 116 ;'t'
.db 121 ;'y'
.db 112 ;'p'
.db 101 ;'e'
.db 100 ;'d'
.db 32 ;' '
.db 13 ;<CR>
.db 10 ;<LF>
答 1: 唉,地址忘记乘2了,郁闷
.def u_sr =r15 ;Status-register storage
.def temp =r16 ; Define temporary variable
.def TIME_H =r17 ; Define timer variable high 8 bits
.def TIME_L =r18 ; Define timer variable low 8 bits
.cseg
.org $0000
rjmp RESET ;Reset handle
.org OVF0addr
rjmp tim0_ovf ;Timer0 overflow handler
tim0_ovf:
reti
RESET: ldi temp,low(RAMEND)
out SPL,temp ; Set stack pointer to last internal RAM location
ldi temp,high(RAMEND)
out SPH,temp
ldi temp,0
out DDRC,temp
sbi DDRB,DDB5 ; except PD4 -> output with 1's
ldi temp,1<<TOIE0 ;Set bit 1 in u_tmp
out TIFR,temp ; to clear T/C0 overflow flag
out TIMSK,temp ; and enable T/C0 overflow interrupt
out TCNT0,temp ;Set timer reload-value (1 bit)
sei
loop:
in temp,PINC
lsl temp
ldi ZH,0x04 ; Load high part of byte address into ZH
ldi ZL,0x00 ; Load low part of byte address into ZL
;ldi ZH,high(2*table) ; Load high part of byte address into ZH
;ldi ZL,low(2*table) ; Load low part of byte address into ZL
lpm
mov TIME_H,r0
inc ZL
lpm
mov TIME_L,r0
rjmp loop
.eseg
.org 0x400
;table:
.db 89 ;'Y'
.db 111 ;'o'
.db 117 ;'u'
.db 32 ;' '
.db 116 ;'t'
.db 121 ;'y'
.db 112 ;'p'
.db 101 ;'e'
.db 100 ;'d'
.db 32 ;' '
.db 13 ;<CR>
.db 10 ;<LF>
答 1: 唉,地址忘记乘2了,郁闷
共3条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |