Keil™, An ARM® Company

Technical Support

C166: RUNNING CODE FROM IDATA


Information in this article applies to:

  • C166 Version 3.12
  • C166 Version 4.03

QUESTION

I'm using the Siemens 80C166/C167 and I want to copy code (that changes bus modes) from ROM to the on-chip RAM and execute it there. How can I do this?

ANSWER

The following code example executes code in the on-chip RAM to switch CPU modes from 8 to 16 bit and/or mux to non-mux. According to Siemens specification, this must be exectuted in on-chip RAM. The code copied can only contain relative addressing.

;----------------------------------------------------------
; This copies the mode switch subroutine to internal RAM
; (it must be executed there as per Siemens spec)
;
; The following code is written into internal RAM
;
;$FC2E:
;  AND P2,01FFh                 ; set output port on PRO166/7
;  MOV SYSCON,  04FFh           ; set CPU mode
;  NOP                          ; give it time to settle (REQUIRED)
;  RET                          ; return to external memory execution
;----------------------------------------------------------

                MOV     R6,#0FC2EH              ; destination in on-chip RAM

                MOV     R5,#0E066H              ; Opcode: AND P2,
                MOV     [R6],R5
                ADD     R6,#02H

                MOV     R5,# 0001111111111111b  ; Data: Port 2 non-mux,16-bit, norom
                MOV     [R6],R5
                ADD     R6,#02H

                MOV     R5,#086E6H              ; Opcode: MOV SYSCON,
                MOV     [R6],R5
                ADD     R6,#02H

                MOV     R5,#04FFH               ; Data: Fast 16-bit non-mux
                MOV     [R6],R5
                ADD     R6,#02H

                MOV     R5,#0CCH                ; Opcode: NOP
                MOV     [R6],R5
                ADD     R6,#02H

                MOV     R5,#0CBH                ; Opcode: RET
                MOV     [R6],R5

                CALLA   cc_UC,0FC2Eh            ; execute snippet in internal RA

MORE INFORMATION

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Wednesday, June 01, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure