Download AN708 Translating 8051 assembly code to XA

Transcript
Philips Semiconductors
Application note
Translating 8051 assembly code to XA
AN708
2.2.4 Feeding the Watchdog
There is one critical mechanism provided on the XA that has no equivalent in the basic 80C51 architecture (but is implemented in some 80C51
derivatives): the watchdog timer. If you fail to pay attention to the watchdog timer—which is activated automatically by a hardware reset—your
translated applications will crash mysteriously!
Fortunately, it is very easy to take care of the watchdog. For most developmental purposes, we recommend simply deactivating the entire
subsystem early in your XA initialization code. (Right after stack pointer initialization is a good place.) We will draw again from the complete
startup initialization template in Appendix 1. The watchdog timer uses a special “feeding” sequence to enable any changes to its configuration:
wdoff:
...
mov.b
mov.b
mov.b
equ $00
; WDCON value to turn off WD
wdcon,#wdoff
wfeed1,#$a5
wfeed2,#$5a
; Turn off watchdog timer.
; Feed watchdog: use new config
This code sequence deactivates the watchdog subsystem and places it in a known state.
The watchdog mechanism is not implemented in the XA Tools simulator, and these instructions will have no effect.
2.2.5 Obligatory Hardware Initialization
The XA contains a number of hardware initialization registers. (Namely, BCR, BTRH, BTRL, P0CFGA, P0CFGB, P1CFGA, P1CFGB, P2CFGA,
P2CFGB, P3CFGA, and P3CFGB.) The default power-up values of these are often sufficient to get your application running, but the defaults
won’t work in every case, and we recommend that you consider initializating these registers as obligatory among the first instructions after reset.
You’ll definitely need to use non-default values to speed up external memory access and to enable external RAM access when executing code
in internal code space.
Explaining how to set all these registers is well beyond the scope of this document, but we’ll give a common example, taken from Appendix 1:
mov.b
mov.b
mov.b
mov.b
mov.b
mov.b
mov.b
mov.b
mov.b
mov.b
mov.b
bcr,#waitd+bus16+adr20
btrh,#dw5+dwa5+dr4+dra5
; Set up bus configuration.
; Config bus timing to longest
; bus cycles
btrl,#wrpuls2+holdmin+ale05+cr4+cra5 ; short ALE, min data
; hold.
p0cfga,#pcfga_pp
p0cfgb,#pcfgb_pp
p1cfga,#p1cfga_bus
p1cfgb,#p1cfgb_bus
p2cfga,#pcfgb_pp
p2cfgb,#pcfgb_pp
p3cfga,#p3cfga_bus
p3cfgb,#p3cfgb_bus
; Configure port0 types for bus.
; Configure P1 for quasi–bidirec
; except A3 – A0 are push–pull.
; Configure P2 types for bus.
; Configure P3 for quasi–bidirect
; except WR, RD are push–pull.
This won’t have any effect on the XA simulator. See section 7.3 in the XA User Guide for more details.
1996 Dec 30
15