*** paulmon21.asm Wed Jul 12 05:25:53 2000 --- paulmon21flash.asm Fri Jul 26 01:56:38 2002 *************** *** 1,4 **** ! ; PAULMON2, a user-friendly 8051 monitor, by Paul Stoffregen ; Please email comments, suggestions, bugs to paul@pjrc.com ; Version 2.1, flash rom changed from 28F256 (obsolete) to --- 1,23 ---- ! ;; PAULMON2 alterations (c) Matt Evans, 5/May 2002 18:51 ! ;; evansm7@cs.man.ac.uk, http://www.cs.man.ac.uk/~evansm7/projects/ ! ;; or matt@axio.ms ! ;; For dallas 89C420 to map in the 1K SRAM as ! ;; PROGRAM memory (so paulmon can download to it!) ! ;; This is done by setting ROMSIZE(0xC2).3, PRAMEn. ! ;; The SRAM is mapped in as prog memory at 0x0400 :-/ ! ! ;; So, a hole needs to be made in paulmon at this space. ! ! ;; I do this by having the interrupt vectors at address 0 ! ;; and NOTHING else. base = 0x800, so paulmon starts there. ! ;; (plenty of space in flash.. about 0x100 to 0x3ff is free) ! ! ;; See comments below, in 'poweron' routine. ! ! .equ SRAMSTART, 0x0400 ! .equ SRAMEND, 0x0800 ; The next free byte, that is ! ! ; PAULMON2, a user-friendly 8051 monitor, by Paul Stoffregen ; Please email comments, suggestions, bugs to paul@pjrc.com ; Version 2.1, flash rom changed from 28F256 (obsolete) to *************** *** 59,66 **** ; These two parameters control where PAULMON2 will be assembled, ; and where it will attempt to LJMP at the interrupt vector locations. ! .equ base, 0x0000 ;location for PAULMON2 ! .equ vector, 0x2000 ;location to LJMP interrupt vectors ; These three parameters tell PAULMON2 where the user's memory is ; installed. "bmem" and "emem" define the space that will be searched --- 78,86 ---- ; These two parameters control where PAULMON2 will be assembled, ; and where it will attempt to LJMP at the interrupt vector locations. ! .equ base, 0x0800 ;location for PAULMON2 ! .equ vbase, 0x0000 ;location for vectors ! .equ vector, 0x0400 ;location to LJMP interrupt vectors ; These three parameters tell PAULMON2 where the user's memory is ; installed. "bmem" and "emem" define the space that will be searched *************** *** 70,83 **** ; may reconfigure it unexpectedly. If flash rom is used, "bmem" and "emem" ; should also include the space where the flash rom is mapped. ! .equ pgm, 0x2000 ;default location for the user program ! .equ bmem, 0x1000 ;where is the beginning of memory .equ emem, 0xFFFF ;end of the memory ; To set the baud rate, use this formula or set to 0 for auto detection ; baud_const = 256 - (crystal / (12 * 16 * baud)) ! .equ baud_const, 0 ;automatic baud rate detection ;.equ baud_const, 255 ;57600 baud w/ 11.0592 MHz ;.equ baud_const, 253 ;19200 baud w/ 11.0592 MHz ;.equ baud_const, 252 ;19200 baud w/ 14.7456 MHz --- 90,104 ---- ; may reconfigure it unexpectedly. If flash rom is used, "bmem" and "emem" ; should also include the space where the flash rom is mapped. ! .equ pgm, 0x0400 ;default location for the user program ! .equ bmem, 0x0400 ;where is the beginning of memory .equ emem, 0xFFFF ;end of the memory ; To set the baud rate, use this formula or set to 0 for auto detection ; baud_const = 256 - (crystal / (12 * 16 * baud)) ! .equ baud_const, 250 ; 115200 with T1CLK=clk w/ 11.0592 ! ;.equ baud_const, 0 ;automatic baud rate detection ;.equ baud_const, 255 ;57600 baud w/ 11.0592 MHz ;.equ baud_const, 253 ;19200 baud w/ 11.0592 MHz ;.equ baud_const, 252 ;19200 baud w/ 14.7456 MHz *************** *** 211,267 **** ; ; ;---------------------------------------------------------; ! .org base ljmp poweron ;reset vector ! ! .org base+3 ljmp vector+3 ;ext int0 vector r6r7todptr: mov dpl, r6 mov dph, r7 ! ret ! ! .org base+11 ! ljmp vector+11 ;timer0 vector ! dptrtor6r7: mov r6, dpl mov r7, dph ret - - .org base+19 - ljmp vector+19 ;ext int1 vector - dash: mov a, #'-' ;seems kinda trivial, but each time ajmp cout ;this appears in code, it takes 4 nop ;bytes, but an acall takes only 2 - - .org base+27 - ljmp vector+27 ;timer1 vector - cout_sp:acall cout ajmp space - nop - - .org base+35 - ljmp vector+35 ;uart vector - dash_sp:acall dash ajmp space ! nop ! ! .org base+43 ! ljmp vector+43 ;timer2 vector (8052) ! ! ! ;---------------------------------------------------------; ! ; ; ! ; The jump table for user programs to call ; ! ; subroutines within PAULMON ; ! ; ; ! ;---------------------------------------------------------; ! .org base+46 ;never change this line!! Other ;programs depend on these locations ;to access paulmon2 functions --- 232,285 ---- ; ; ;---------------------------------------------------------; ! .org vbase ljmp poweron ;reset vector ! ! .org vbase+3 ljmp vector+3 ;ext int0 vector + + .org vbase+11 + ljmp vector+11 ;timer0 vector + + .org vbase+19 + ljmp vector+19 ;ext int1 vector + + .org vbase+27 + ljmp vector+27 ;timer1 vector + + .org vbase+35 + ljmp vector+35 ;uart vector + + .org vbase+43 + ljmp vector+43 ;timer2 vector (8052) + + + ;---------------------------------------------------------; + ; ; + ; The jump table for user programs to call ; + ; subroutines within PAULMON ; + ; ; + ;---------------------------------------------------------; + + .org base ; ok, real paulmon code now r6r7todptr: mov dpl, r6 mov dph, r7 ! ret dptrtor6r7: mov r6, dpl mov r7, dph ret dash: mov a, #'-' ;seems kinda trivial, but each time ajmp cout ;this appears in code, it takes 4 nop ;bytes, but an acall takes only 2 cout_sp:acall cout ajmp space dash_sp:acall dash ajmp space ! ! .org base+46 ;never change this line!! Other ;programs depend on these locations ;to access paulmon2 functions *************** *** 1828,1833 **** --- 1846,1877 ---- mov p2, a mov p3, a mov sp, #stack + + ;; me: enable on-chip SRAM for the 89c420 + ;; TIMED ACCESS ONLY! :-/ So, need to do: + ;; Write 0xaa to timed access reg (0xc7) + ;; write 0x55 to timed access reg + ;; write bit + mov A,#0x0d ; 16k flash, PRAME on + + mov TA,#0xaa + mov TA,#0x55 + + mov ROMSIZE,A ; SRAM mapped as program mem at 0x0400 + ;; This blats out anythign that was there! hence hole up there ^ + ;; Don't set the SRAM up as data memory. confusing since + ;; it's in a different place and all. lookup tables + ;; must use movC!!!! + + orl 0xC4,#0x81 ; Data memory; sram is 0-0x3ff(DATA) PMR + ; ; clk is clk/1 + + ;; Set timer 1 clock to clk/4 not clk/12 (alter baud rate too!) + orl 0x96,#0x10 ; Bit 4 of TIMERCTL + ;; this is T1MH=1, timer 1 clock = clk + + ;; Need to use 256-6 = 250 for baud rate + ;Before we start doing any I/O, a short delay is required so ;that any external hardware which may be in "reset mode" can