| Details | Message |
|---|
Read-Only Author Rinfen Liu Posted 10-Oct-2003 06:28 GMT Toolset None |  Why does my program always start from C:0x00AE? Rinfen Liu Dear all,
Thank you for your help in advance.
I created a very simple program to test my Monitor-51 which is showed below:
#include "AT89X55.H"
sbit P25 = 0xA5;
void DELAY(int j)
{
int i;
for(;j>0;j--)
{
for(i=2;i>0;i--)
{;}
}
}
main(){
while(1)
{
P25 = 0;
DELAY(1);
P25 = 1;
DELAY(1);
}
}
When I debugged this program by using Monitor-51,the first line is always "C:0x0000 0200AE LJMP c:00AE" in the Disassembly window,and the other lines are:
...
C:0x00AE E4 CLR A
C:0x00AF F5CB MOV RCAP2H(0xCB),A
C:0x00B1 F5CA MOV RCAP2L(0xCA),A
C:0x00B3 F5CC MOV TL2(0xCC),A
C:0x00B5 F5CD MOV TH2(0xCD),A
C:0x00B7 F5C9 MOV T2MOD(0xC9),A
C:0x00B9 F5C8 MOV T2CON(0xC8),A
C:0x00BB 20B0FD JB RXD(0xB0.0),C:00BB
C:0x00BE 30B0FD JNB RXD(0xB0.0),C:00BE
C:0x00C1 D2CA SETB TR2(0xC8.2)
C:0x00C3 30B003 JNB RXD(0xB0.0),C:00C9
C:0x00C6 30CFFA JNB TF2(0xC8.7),C:00C3
C:0x00C9 30B0FD JNB RXD(0xB0.0),C:00C9
C:0x00CC 30B003 JNB RXD(0xB0.0),C:00D2
C:0x00CF 30CFFA JNB TF2(0xC8.7),C:00CC
C:0x00D2 30B0FD JNB RXD(0xB0.0),C:00D2
C:0x00D5 C2CA CLR TR2(0xC8.2)
C:0x00D7 20CFD4 JB TF2(0xC8.7),C:00AE
C:0x00DA AFCC MOV R7,TL2(0xCC)
C:0x00DC AECD MOV R6,TH2(0xCD)
C:0x00DE EE MOV A,R6
C:0x00DF C3 CLR C
...
And I failed to change the statement by use of "Inline assembly".Why the assembly try to initial the timer2? I wonder if the MON51.HEX createad by INSTALL.A51 is fit to AT89S52? The MCU is AT89S52. I set the Option for target as follow: Off-chip code memory Start:0x8000, size:0x3fff, Off-chip Xdata memory Start:0xc000, size:0x3fff. When I use simulator to debug this program there is no problem. Can you give me a hand? Thanks. |
|
Read-Only Author Andy Neil Posted 10-Oct-2003 07:28 GMT Toolset None |  RE: Why does my program always start from C:0x00AE? Andy Neil The MON51 documentation will tell you what resources it requires in your hardware. Have you checked? |
|
Read-Only Author Rinfen Liu Posted 10-Oct-2003 10:10 GMT Toolset None |  RE: Why does my program always start from C:0x00AE? Rinfen Liu Yes. I have checked it carefully according to MON51. |
|
Read-Only Author Andrew Neil Posted 10-Oct-2003 13:07 GMT Toolset None |  RE: Why does my program always start from C:0x00AE? Andrew Neil "Why the assembly try to initial the timer2?"
Because that's what it says on the tin:
"The monitor [MON51] uses a serial interface with a timer as the baudrate generator." (my emphasis)
It's in the uVision Getting Started Guide - in the MON51 section. |
|
Read-Only Author Jon Ward Posted 10-Oct-2003 10:16 GMT Toolset None |  RE: Why does my program always start from C:0x00AE? Jon Ward The LJMP you see is where the reset vector jumps to the monitor program.
If you program must start at address 0x8000 (when using the monitor) then you must do more than simply specifying the starting CODE address. Refer to the following knowledgebase article:
http://www.keil.com/support/docs/189.htm
Once the program downloads to the monitor, you may also have to specify the starting address ($ = 0x8000). It's probably a good idea to uncheck Go Til Mail in the debugger options.
Jon |
|
Read-Only Author Rinfen Liu Posted 14-Oct-2003 06:29 GMT Toolset None |  RE: Why does my program always start from C:0x00AE? Rinfen Liu Thank you. My setup is just as what "C51: SETTING PROGRAM START ADDRESS" says and I got the same result. In addition, when I stepped over the program,it halt at
C:0x00AF F5CB MOV RCAP2H(0xCB),A ,then I pressed the "reset" button on the MONITOR51 board and received error information "try again"/"setting"/stop session". I selected "try again",now the PC jumped to 0x8000. |
|
Read-Only Author Jon Ward Posted 14-Oct-2003 17:46 GMT Toolset None |  RE: Why does my program always start from C:0x00AE? Jon Ward Why does my program always start from C:0x00AE?
This question reminds me of a Peter Sellers movie.
A man asks an innkeeper, "Does your dog bite?" The innkeeper said, "No." The man leans over to pet the dog and the dog nearly eats his hand off. He turns to the innkeeper and says, "I thought you said your dog did not bite." The innkeeper responds, "That is not my dog."
I guess my smart-aleck answer to "Why does my program always start from C:0x00AE?" is, "That is not your program!"
Jon |
|
Read-Only Author Patrick Wong Posted 31-Mar-2005 08:57 GMT Toolset C51 |  RE: Why does my program always start from C:0x00AE? Patrick Wong Hi Rinfen,
Did you solve your problem finally? I am encountering a similar problem as yours, i.e. the first line is always
C:0x0000 0200AE LJMP c:00AE
At 0x00AE the instruction is
C28E CLR TR1(0x88.6)
once I step this the monitor losts connections with uVision2...
I follow exactly what mentioned in "C51: SETTING PROGRAM START ADDRESS" however the reset vector persists as 0x00AF...
As you suggested after the dialog box appears, reset the target and "Try again", can get the monitor communicates with uVision2 again and can start debugging...
Are there any undocumented steps that I missed to follow? |
|
Read-Only Author Jon Ward Posted 31-Mar-2005 15:31 GMT Toolset C51 |  RE: Why does my program always start from C:0x00AE? Jon Ward That first instruction is the reset for the monitor.
Did you relocate your program to a different starting address?
If so, your program will appear at that address and not at 0000h.
Jon |
|
Read-Only Author Patrick Wong Posted 1-Apr-2005 03:22 GMT Toolset C51 |  RE: Why does my program always start from C:0x00AE? Patrick Wong Hi Jon,
Following instructions in "C51: SETTING PROGRAM START ADDRESS", I did:
Change the startup code...
1. Copy the STARTUP.A51 file from the \C51\LIB directory to my project directory.
2. Search for CSEG AT 0000h and change it to CSEG AT 8000h.
3. Add the startup code to my project.
Locate the interrupt vectors (uVision Version 2)...
1. Select Options for Target from the Project menu.
2. Select the C51 tab.
3. Check the Interrupt vectors at address checkbox.
4. Change the offset to 0x8000.
Specify the code area for the linker (uVision Version 2)...
1. Select Options for Target from the Project menu.
2. Select the Target tab.
3. Change the EPROM starting address to 0x8000.
Rebuild my program and check the M51 map file as:
BL51 BANKED LINKER/LOCATER V5.03, INVOKED BY:
C:\KEIL\C51\BIN\BL51.EXE STARTUP.obj, TEST.obj TO TESTMON CODE (0X8000-0XFDFF) XDATA (0XFF00-0XFFFF)
MEMORY MODEL: LARGE
INPUT MODULES INCLUDED:
STARTUP.obj (?C_STARTUP)
TEST.obj (TEST)
LINK MAP OF MODULE: TESTMON (?C_STARTUP)
TYPE BASE LENGTH RELOCATION SEGMENT NAME
-----------------------------------------------------
* * * * * * * D A T A M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
IDATA 0008H 0006H UNIT _IDATA_GROUP_
IDATA 000EH 0001H UNIT ?STACK
* * * * * * * C O D E M E M O R Y * * * * * * *
0000H 8000H *** GAP ***
CODE 8000H 0003H ABSOLUTE
CODE 8003H 0051H UNIT ?PR?MAIN?TEST
CODE 8054H 003DH UNIT ?PR?_DELAY?TEST
CODE 8091H 000CH UNIT ?C_C51STARTUP
OVERLAY MAP OF MODULE: TESTMON (?C_STARTUP)
SEGMENT IDATA_GROUP
+--> CALLED SEGMENT START LENGTH
----------------------------------------------
?C_C51STARTUP ----- -----
+--> ?PR?MAIN?TEST
?PR?MAIN?TEST 0008H 0002H
+--> ?PR?_DELAY?TEST
?PR?_DELAY?TEST 000AH 0004H
SYMBOL TABLE OF MODULE: TESTMON (?C_STARTUP)
VALUE TYPE NAME
----------------------------------
------- MODULE ?C_STARTUP
C:8091H SEGMENT ?C_C51STARTUP
I:000EH SEGMENT ?STACK
C:8000H PUBLIC ?C_STARTUP
N:0000H SYMBOL IBPSTACK
N:0100H SYMBOL IBPSTACKTOP
N:0080H SYMBOL IDATALEN
C:8094H SYMBOL IDATALOOP
N:0000H SYMBOL PBPSTACK
N:0000H SYMBOL PBPSTACKTOP
N:0000H SYMBOL PDATALEN
N:0000H SYMBOL PDATASTART
N:0000H SYMBOL PPAGE
N:0000H SYMBOL PPAGEENABLE
D:0081H SYMBOL SP
C:8091H SYMBOL STARTUP1
N:0000H SYMBOL XBPSTACK
N:0000H SYMBOL XBPSTACKTOP
N:0000H SYMBOL XDATALEN
N:0000H SYMBOL XDATASTART
C:8000H LINE# 81
C:8091H LINE# 88
C:8093H LINE# 89
C:8094H LINE# 90
C:8095H LINE# 91
C:8097H LINE# 140
C:809AH LINE# 141
------- ENDMOD ?C_STARTUP
------- MODULE TEST
C:0000H SYMBOL _ICE_DUMMY_
D:0090H PUBLIC P1
C:8003H PUBLIC main
B:0090H.5 PUBLIC green_led
B:0090H.4 PUBLIC red_led
C:8054H PUBLIC _delay
------- PROC MAIN
------- DO
I:0008H SYMBOL i
------- ENDDO
C:8003H LINE# 12
C:8003H LINE# 13
C:8003H LINE# 28
C:8005H LINE# 29
C:8007H LINE# 31
C:8007H LINE# 32
C:8007H LINE# 33
C:800DH LINE# 34
C:800DH LINE# 35
C:800FH LINE# 36
C:8016H LINE# 38
C:802CH LINE# 40
C:8040H LINE# 41
C:8040H LINE# 42
C:8042H LINE# 43
C:8049H LINE# 45
C:8053H LINE# 46
C:8053H LINE# 48
C:8053H LINE# 49
------- ENDPROC MAIN
------- PROC _DELAY
D:0006H SYMBOL t
------- DO
I:000AH SYMBOL q
I:000CH SYMBOL m
------- ENDDO
C:8054H LINE# 51
C:8054H LINE# 52
C:8054H LINE# 55
C:806CH LINE# 56
C:806CH LINE# 57
C:8072H LINE# 58
C:8072H LINE# 59
C:8083H LINE# 60
C:808DH LINE# 62
C:8090H LINE# 63
------- ENDPROC _DELAY
------- ENDMOD TEST
Program Size: data=15.0 xdata=0 code=157
LINK/LOCATE RUN COMPLETE. 0 WARNING(S), 0 ERROR(S)
What else should I do? |
|
Read-Only Author Jon Ward Posted 1-Apr-2005 03:39 GMT Toolset C51 |  RE: Why does my program always start from C:0x00AE? Jon Ward What else should I do?
Modify the settings for the debugger so that it loads the application but so taht it does not run til main.
Then, start the debugger.
Enter $=0x8000 in the command window.
This should show your program's disassembly in the source window.
Jon |
|