Keil Logo Arm Logo

Keil's Simulation is right or wrong?

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
chen jun
Posted
2-May-2008 02:07 GMT
Toolset
C51
New! Keil's Simulation is right or wrong?

The MCU I used is SM8958A,which has 1K bytes on-chip RAM, 256 bytes of it are the same as general 8052 internal memory structure while the expanded 768 bytes on-chip RAM can be accessed by external memory addressing method (by instruction MOVX).The SCONF and RCON should be setting when the expanded 768 bytes on-chip RAM is used.The meaning of RCON is below:

SM8958A has 768 byte on-chip RAM which can be accessed by external memory addressing method only. (By instruction MOVX). The address space of instruction MOVX @Rn is determined by bit 1 and bit 0 (RAMS1, RAMS0) of RCON. The default setting of RAMS1, RAMS0 bits is 00 (page0).

RAMS1 RAMS0  MOVX @Ri i=0,1 mapping to expended RAM address

 0     0             ~ FF
 0     1            $0100 ~ $01FF
 1     0            $0200 ~ $02FF

Now I write the code below:

unsigned long pdata a;
unsigned long xdata b;
SCONF |= 0x02;  //enable the 768 Ram
RCON |= 0x01;  //$0100 ~ $01FF

When I press F5, I find the position of 'a' in the memory is X:0x0001A4,and the auto disassemble instruction is mov r0, #0xA4, however,the position of 'b' in the memory is X:0x0002BF,and the auto disassemble instruction is movx DPTR,#02BF.

Finally, the program where used 'a' runs wrong,but the program where used 'b' runs right.

But when I program the HEX file into the MCU, let it run in the hardware , the program runs ok.

So, I'm very puzzled: Keil's Debug is right or wrong?

Note
This message was edited to reduce width.

Read-Only
Author
Hans-Bernhard Broeker
Posted
2-May-2008 21:33 GMT
Toolset
C51
New! RE: Keil's Simulation is right or wrong?

and the auto disassemble instruction is mov r0, #0xA4

There's nothing wrong with that. So the problem must be elsewhere.

Are you sure that you configured all parts of Keil correctly for using PDATA in page 0x01?
And why use page 01 anyway? It's in the middle of your XRAM, so you're fragmenting your XDATA space for no apparent reason.

Read-Only
Author
chen jun
Posted
6-May-2008 13:05 GMT
Toolset
C51
New! RE: Keil's Simulation is right or wrong?

Thank you for answering my question, can you tell me how to config correctly while using PDATA in page 0x01?
There is what I did:

Device: AT89S52
#include <AT89X52.h>
Memory Model: Small

Read-Only
Author
chen jun
Posted
6-May-2008 13:15 GMT
Toolset
C51
New! RE: Keil's Simulation is right or wrong?

I just define 'a', and do nothing else. The address of 'a' in memory is auto assigned by the simulator,I guess.

Read-Only
Author
chen jun
Posted
6-May-2008 13:17 GMT
Toolset
C51
New! RE: Keil's Simulation is right or wrong?

I am puzzled that while the address of 'a' in memory is X:0x0001A4, the disassemble instruction is mov R0,#0xA4, not mov DPTR,#0x01A4

Read-Only
Author
chen jun
Posted
6-May-2008 13:25 GMT
Toolset
C51
New! RE: Keil's Simulation is right or wrong?

mov R0,#0xA4 just move the value from X:0x0000A4 , not X:0x0001A4, that is what I am puzzled. You know, the address of 'a' in memory is X:0x0001A4 at that time. I'm sorry I did not describe my problem clearly.

Read-Only
Author
erik malund
Posted
6-May-2008 13:53 GMT
Toolset
C51
New! NO, it does not!

mov R0,#0xA4 just move the value from X:0x0000A4
NO, it does not! it moves 0xa4 into r0
I huess the next instructions will be
mov a,@R0
THAT will move what is at xxa4 in memory into the accumulator. xx will be either the contents of P2 (traditional approach) or if your derivative - which I never have heard of - has a "high memory address SFR" by whatever name, it will be the contents of that.

Erik

Read-Only
Author
erik malund
Posted
6-May-2008 15:22 GMT
Toolset
C51
New! RE: NO, it does not! OOPS CORRECTION

mov R0,#0xA4 just move the value from X:0x0000A4
NO, it does not! it moves 0xa4 into r0
I huess the next instructions will be
movX a,@R0
THAT will move what is at xxa4 in memory into the accumulator. xx will be either the contents of P2 (traditional approach) or if your derivative - which I never have heard of - has a "high memory address SFR" by whatever name, it will be the contents of that.

Erik

Read-Only
Author
Hans-Bernhard Broeker
Posted
6-May-2008 23:19 GMT
Toolset
C51
New! RE: Keil's Simulation is right or wrong?

I am puzzled that while the address of 'a' in memory is X:0x0001A4, the disassemble instruction is mov R0,#0xA4, not mov DPTR,#0x01A4

What part of "there's absolutely nothing wrong with that" didn't you get the first time? If PDATA behaved exactly like XDATA to work, why would they exist as separate memory classes in the first place?

Frankly, you need to spend a lot more time on studying the 8051 architecture (memory architecture, opcodes, addressing modes, and all that) before going ahead reading disassembled code and drawing conclusions from what you think you see.

Read-Only
Author
chen jun
Posted
11-May-2008 13:41 GMT
Toolset
C51
New! RE: Keil's Simulation is right or wrong?

Thank you for helping me. Now I understand more than before. I config Pdata in the Startup.A51 file.

Read-Only
Author
chen jun
Posted
11-May-2008 13:55 GMT
Toolset
C51
New! RE: Keil's Simulation is right or wrong?

In simulation, P2 is the uppermost address of pdata variable, but in real mcu, P2 is no effect . So I guess keil's simulation have some flaw.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings