This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

mon51_vs_DS5000

Question :



I had downloaded from KEIL Web site the file "mon51_ds5000.zip" with Mon51,

expanded it to "ds5000_mon_9600_110592.hex" and loaded it into my

DALLAS DS 5000FP 32-16 using "kit.exe" loader with MCON = "E8".



Then I

1.assembled an application :



-----------------------------------------------



void main (void) {

unsigned char a, b ,c;



ES = ENAB ; /* for mon51 only */



a = 2;

b = 3;

c = a+b;



while (1) {

_nop_();

};

}

-----------------------------------------------



2. set in startup.a51 : CSEG AT 2000H



3. set in MVision : C51 - Interrupt vectors at 0x2000

: BL51 Locate - Code Range : 0x2000-0x6FFF

: Debug - Keil monitor 51 driver,

- load application at startup - YES

- go till main - NO

- Settings :9600 Bd,

: stop program execution

with serial input

- Initialization file : debug_mon51.ini

(I wrote down in the ini file :

$ = 0x2000)



4.compiled all the files above successfully together



5. loaded intelhex of the application to my DS 5000 via mon51 (without

receiving any error mesages).



After loading the application I can see in MVision on the monitor, that program

counter is set to main function, but after a short while program counter

"crash" to address 0x0000.



The thing is that program counter is hunged on address 0x0000 and

I am not able to run program using single stepping.

However, I can successful place a breakpoint anywhere in main function,



When I enter command "$ - main" I can see a code of my application with

break point placed, but I can't single step the application. When trying it,

program counter everywhrere "crashes" to address 0x0000.



Could someone to tell me what I am doing incorecctly ?



I have tried manually create mon51 modifying file Install.a51 according

to instructions on Keil Web site and added this code in install.a51 :



----------------------------------------------------------------------



USER_PGM_START EQU 2000H

USER_PGM_MCON EQU 048H ; partition CODE/DATA : 0x2000

USER_XRAM_MCON EQU 0E8H ; partition CODE/DATA : 0x7000



sfr MCON = 0C6h;

sfr TA = 0C7h;



INT_ADR_OFF EQU USER_PGM_START ; INTERRUPT VECTOR OFFSET IF MONITOR

; IS INSTALLED AT ADDRESS 0000H

DEF_PC_VAL EQU USER_PGM_START ; DEFAULT PC VALUE AFTER START UP





$IF (SERIAL = 0)

;********************************************************************

;* Using TIMER 1 to Generate Baud Rates *

;* Oscillator frequency = 11.059 MHz *

;* Set Baudrate to 9600 Baud *

;********************************************************************



InitSerial: PROMCHECK ; Check if PROM in System



MOV TA,#0AAH ; timed access 1

  • The DS5000 monitor is designed and tested with a DS5000. It has not been tested with a DS5000FP. There are several subtle differences between the DS5000 and DS5000FP, so it is no surprise that the DS5000 monitor may not work on the DS5000FP.

    The monitor for the DS5000 manipulates the MCON register so that it can write into CODE space.

    In the INSTALL.A51 file, the following changes are made near the top:

    .
    .
    .
    EXTRN   CODE (MON51)    ; START OF MONITOR-51
    EXTRN   CODE (SER_ISR)  ; SERIAL INTERRUPT SERVICE ROUTINE
    
    ;------------------------------------------------------------------------
    ; Change these to match the starting address for the user program.
    ; Get the MCON values from the Dallas Soft Microcontrollers Databook.
    ; Since the monitor data area is located at 1F00h, set the partition at
    ; 1800h (MCON = 3X).
    ;
    ; Memory Map
    ;-------------------------------
    ; C:0000-17FF   On-chip Monitor
    ; C:1800-1EFF   On-chip Unused
    ; C:1F00-1FFF   On-chip Monitor Data Area
    ; C:2000-6FFF   On-chip User Program
    ; C:7000-FFFF   Off-chip
    ;
    ; X:0000-6FFF   Off-chip
    ; X:7000-7FFF   On-chip User XDATA
    ; X:8000-FFFF   Off-chip
    ;------------------------------------------------------------------------
    USER_PGM_START	EQU	2000H
    USER_PGM_MCON	EQU	30H        ; 1800h
    USER_XRAM_MCON  EQU     0E0H       ; 7000h
    
    sfr MCON = 0C6h;
    sfr TA   = 0C7h;
    
    ;------------------------------------------------------------------------
    ; !!! Don't change these. !!!
    ;------------------------------------------------------------------------
    INT_ADR_OFF 	EQU USER_PGM_START	; INTERRUPT VECTOR OFFSET IF MONITOR
    		                        ; IS INSTALLED AT ADDRESS 0000H
    DEF_PC_VAL	EQU USER_PGM_START	; DEFAULT PC VALUE AFTER START UP
    
    ;------------------------------------------------------------------------
    ;------------------------------------------------------------------------
    .
    .
    .

    The InitSerial routine is modified as follows to set the MCON register:

    InitSerial:
    
    		PROMCHECK               ; Check if PROM in System
    
    		MOV  	TA,#0AAH
    		MOV  	TA,#055H
    		ORL  	MCON,#02h	; Set PAA
    
    		MOV  	MCON,#USER_XRAM_MCON
    
    		MOV  	TA,#0AAH
    		MOV  	TA,#055H
    		ANL  	MCON,#0FDh	; Clear PAA
    
                    MOV     TMOD,#00100000B ;C/T = 0, Mode = 2
                    MOV     TH1,#0FDH
                    SETB    TR1
                    MOV     SCON,#01011010B ; Init Serial Interface
    
    		JMP     Mon51
    

    And, the WR_CODE stub is modified to manipulate the MCON register as follows:

    WR_CODE:
    		SETB	C
    		JBC	EA, C_SET
    		CLR	C
    C_SET:		PUSH	PSW		; Save Interrupts
    		CLR  	EA		; Disable Interupts
    
    		MOV  	TA,#0AAH
    		MOV  	TA,#055H
    		ORL  	MCON,#02h	; Set PAA
    
    		MOV  	MCON,#USER_PGM_MCON
    	        MOVX    @DPTR,A
    		MOV  	MCON,#USER_XRAM_MCON
    
    		MOV  	TA,#0AAH
    		MOV  	TA,#055H
    		ANL  	MCON,#0FDh	; Clear PAA
    
    		POP	PSW		; Restore Interrupts
    		MOV	EA,C
    
                    RET
    

    Maybe these things will give an insight into how to modify the monitor for the DS5000FP.

    Jon

  • Dear Jon

    thank you for your advice. I modified install.a51 exactly as you
    recommended (without modifying parametres :
    USER_PGM_MCON EQU 30H ; 1800h
    USER_XRAM_MCON EQU 0E0H ; 7000h

    What's more I compiled mon51 using install 0 7f) with mon51x.lib
    instead of mon51.lib
    as was recommended by other author in the Keil's discussion forum.

    After it I loaded mon51 to my DS 5000 (using kit.exe with MCON set to E8),
    then I loaded my application which started at 0x2000 with ini file
    like this :
    $=0x2000
    g,main

    (it seems to have a certain importancy when just the two commands are used in
    ini file for mVision debugger using mon51)

    Situation now differs from described previously.
    Program counter is correctly set on first instruction of function main
    and local variables are correctly initialized to zeros.
    I am able to single step my application ant put breaks.


    When I want to single step my program via MVision programs falls after
    a while to command :

    C:0x2000 022010 LJMP STARTUP1(C:2010)

    What is interesting, when I am using the command "Run to cursor line"
    in mVision and thus, simulate "single stepping", I can see that my
    application runs
    because of changing content of accumulator and registers seen in
    Register windows, In addition, changes (seen in Watch window) appear to be
    in agreement (partly) with my application.

    Then I fixed my eyes on MCON a DALLAS family micons. I must admit that
    I caused a bit misunderstanding in my last contribution to Keil's discussion
    forum.
    I have searched in Dallas data book for detailed information on my
    DS 5000 and where is what I've found :
    I 've got module DS 5000 32 - 16, in 40 pIN DIP, which consist of
    chip called DS 5000 FP and internal 32 kbyte NVRAM.
    As far as MCON is concerned : bits MCON.7-4 are used for partitioning like
    this :
    PA3 PA2 PA1 PA0 Partition Address
    0 0 0 0 0000H
    0 0 0 1 0800H
    0 0 1 0 1000H
    0 0 1 1 1800H
    0 1 0 0 2000H
    0 1 0 1 2800H
    0 1 1 0 3000H
    0 1 1 1 3800H
    1 0 0 0 4000H
    1 0 0 1 4800H
    1 0 1 0 5000H
    1 0 1 1 5800H
    1 1 0 0 6000H
    1 1 0 1 6800H
    1 1 1 0 7000H
    1 1 1 1 8000H

    I would say that all DS 5000 are using this scheme. Settings of MCON
    can only differ when considering internal NVRAM of module DS 5000, which
    can be 8 kbyte or 32 kbyte. This information called "range adress"
    is to set in MCON.3 to 1 if used DS5000 has 32 kbyte of NVRAM
    (which is my case) instead of only 8 kbyte.

    The remaining bits of MCON should be set as follows :

    MCON.2 - to 0 if the DS 5000 doesn't contain a real time clock
    MCON.1 - it's PAA bit vith known meaning
    MCON.0 - security lock - initation of security set, if security is not
    set it has value = 0

    Regarding these information I modified install.a51 only as follows :

    USER_PGM_START EQU 2000H
    USER_PGM_MCON EQU 38H ; 1800h uses 32 kbyte NVRAM
    USER_XRAM_MCON EQU 0E8H ; 7000h uses 32 kbyte NVRAM

    then compiled new mon51 using : 0 7f and loaded it into DS 5000.
    Then I started mVision, loaded my aplication and I
    put a breakpoint at the end of main function and started degug
    (till the break).
    Running correctly stopped when the breakpoint was reached and
    contents of variables in Watch window seem to change according what
    was programed in main function of the application.
    Again , I was not abl