WAIT: SJMP $
SJMP WAIT
VVV said:Do it this way:
Code:WAIT: SJMP $ SJMP WAIT
WAIT: nop
nop
nop
jmp WAIT
;****************************************************
;8051 INTERRUPT EXAMPLE(10-khz SQUARE WAVE)
;
ORG 0 ;RESET ENTRY POINT
LJMP MAIN ;JUMP ABOVE INTERRUPT VECTORS
ORG 000BH ;Timer 0 INTERRUPT VECTOR
TOISR: CPL P1.0 ;TOGGLE PORT BIT
RETI
ORG 0030H
MAIN: MOV TMOD,#02H ;Timer 0,MODE 2
MOV THO,#-50 ;50us DELAY
SETB TR0 ;START TIMER
MOV IE,#82H ;ENABLE TIMER 0 INTERRUPT
SJMP $ ;DO NOTHING
AES51 PAGE 1
1 ;
2 ; D51 V2.6 8051 Disassembly of aes51.hex
3 ; 10/23/2007 1:59
4 ;
00E0 5 acc equ 0E0h
0080 6 p0 equ 80h
0090 7 p1 equ 90h
00A0 8 p2 equ 0A0h
00B0 9 p3 equ 0B0h
10
11
0000 12 org 0
13 ;
0000 6187 14 X0000: ajmp X0387
15 ;
0003 16 org 3
17 ;
0003 20312D 18 jb 26h.1,X0033
0006 C000 19 push psw
0008 024003 20 ljmp X4003
21 ;
000B C000 22 push psw
000D 202E10 23 jb 25h.6,X0020
0010 02400B 24 ljmp X400b
25 ;
0013 20122B 26 jb 22h.2,X0041
0016 C000 27 push psw
0018 024013 28 ljmp X4013
29 ;
001B C000 30 push psw
001D 021F78 31 ljmp X1f78
32 ;
0020 0218FA 33 X0020: ljmp X18fa
34 ;
0023 C000 35 push psw
0025 201F1C 36 X0025: jb 23h.7,X0044
0028 024023 37 ljmp X4023
38 ;
002B C000 39 push psw
002D 02402B 40 ljmp X402b
41 ;
0030 021934 42 X0030: ljmp X1934
43 ;
0033 202608 44 X0033: jb 24h.6,X003e
0036 C296 45 clr p1.6
0038 3000FD 46 X0038: jnb int0,X0038
003B D296 47 setb p1.6
003D 32 48 reti
49 ;
003E 022040 50 X003e: ljmp X2040
51 ;
0041 D216 52 X0041: setb 22h.6
0043 32 53 reti
54 ;
0044 022050 55 X0044: ljmp X2050
56 ;
0047 17 57 X0047: dec @r1
0048 7C12 58 mov r4,#12h
org 400BH
TOISR:
cpl p1.5
reti
org 7000h
main:
mov tmod,#02h
mov th0,#-50
setb tr0
mov ie,#82h
WAIT: SJMP $
SJMP WAIT
end
TOISR:
cpl p1.5
reti
Well, that depends on the state of bit 25h.6:I saw over here, that on 000BH location, the controller is jumping to 400BH.
If the bit is set the program goes away someplace:000D 202E10 23 jb 25h.6,X0020
...and who knows what goes on there - some BASIC-52 stuff I presume...0020 0218FA 33 X0020: ljmp X18fa
I'd guess your program is not the only thing running in the chip...0000 6187 14 X0000: ajmp X0387
org 400BH
TOISR:
cpl p1.4
reti
org 7000h
main:
; I am clearing the bit 25h.6 in the start of program to ensure it has not been set up previously by its firmware which ran before my program.
; 02eh = bit 25h.6
clr 02eh
mov tmod,#02h
mov th0,#-50
setb tr0
mov ie,#82h
WAIT: clr 02eh
SJMP WAIT
end
push psw ;save PSW on stack
jb 25h.6,X0020 ;jump if bit 25.6 set to LABEL X0020
ljmp X400b ;unconditional jump to LABEL X400b
Wait: clr 25h.6
Jmp Wait
mov th0,#-50
org 400BH
TOISR:
cpl p1.4
reti
org 7000h
main:
mov tmod,#02h
mov th0,#-50
setb tr0
mov ie,#82h
WAIT: clr 02eh ; 25h.6=02eh
SJMP WAIT
end
jb 25h.6,X0020
X0020: ljmp X18fa
ljmp X400b
;----------------------------------------------------------------------------------------
;Fixed program locations
;
CSEG AT RESET
jmp MainProg
CSEG AT TIMER0
jmp T0ISR
;----------------------------------------------------------------------------------------
;Timer 0 ISR
;
T0ISR: cpl P1.4
reti
;----------------------------------------------------------------------------------------
;Mainprogram with endless loop
;
MainProg: mov TMOD,#02h ;Setup Timer0
mov TH0,#205
setb TR0
mov ie,#82h
WAIT: clr 02Eh ;Clear whatever bit
sjmp WAIT
END
My code "CSEG AT RESET" is equal to ORG 0000h
My code "CSEG AT TIMER0" is equal to ORG 000Bh
you can check those addresses in the word document.
Problem is you can't access those since they are in EPROM
org 401BH
TOISR:
cpl p1.4
reti
org 7000h
main:
anl TMOD, #0FH ;clear Timer 1 control
mov TMOD, #020h ;
mov TL1, #00h ;value set by user
mov TH1, #0D2h ;value set by user
setb IE.3
setb TR1 ;TCON.6 start timer 1
sjmp $
end
000B C000 22 push psw
000D 202E10 23 jb 25h.6,X0020
0010 02400B 24 ljmp X400b
001B C000 30 push psw
001D 021F78 31 ljmp X1f78
001B 0000 30 nop
001D 02401B 31 ljmp 401Bh
org 400BH
TOISR:
cpl p1.4
pop psw
reti
Absolutely not !!wek said:Now I see what's the problem - stack corruption.
mcs51mc said:What happend at LABEL X400b when bit 25h.6 is cleared is still unknown since we never saw the code at that label.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?