chiark / gitweb /
memory erase on master's startup
authorian <ian>
Fri, 30 Dec 2005 12:15:40 +0000 (12:15 +0000)
committerian <ian>
Fri, 30 Dec 2005 12:15:40 +0000 (12:15 +0000)
detpic/misc.asm
detpic/program.asm

index ad5769682d3f8b63e508b44bdc12cfffd96b2bc4..5076592fbd481aa1039f58e68991a8b5cdf47801 100644 (file)
@@ -1,8 +1,16 @@
 ;======================================================================
 
   include common.inc
-  code
 
+  udata_acs
+dsave_w                res     1
+dsave_fsr0     res     2
+debugp res     1
+
+debug_section udata 0x100
+debug  res     256
+
+  code
 ;======================================================================
 ; GENERALLY USEFUL ROUTINES
 
@@ -49,4 +57,53 @@ init_bitnum2bit_loop
        bra_nn  init_bitnum2bit_loop
        return
 
+;----------
+memory_erase @
+;  picno                       preserved
+;  idloc1                      preserved
+;  other GPRs                  overwritten with 0xbb
+       mov_ff  picno, FSR1L
+       mov_ff  idloc1, TABLAT
+       mov_lfsr 0, 0
+memory_erase_pageloop
+       mov_lw  0xbb
+memory_erase_byteloop
+       mov_wf  POSTINC0
+       mov_wf  POSTINC0
+       mov_wf  POSTINC0
+       mov_wf  POSTINC0
+       mov_wf  POSTINC0
+       mov_wf  POSTINC0
+       mov_wf  POSTINC0
+       mov_wf  POSTINC0
+       tst_f_ifnz FSR0L
+       bra     memory_erase_byteloop
+       ; new page:
+
+       mov_lw  0x05
+       cmp_fw_ifle FSR0H
+       bra     memory_erase_pageloop
+       ; done!
+
+       mov_ff  FSR1L, picno
+       mov_ff  TABLAT, idloc1
+       return
+
+;----------
+debugbyte @
+; Adds a byte to debug
+;  W           message byte            preserved
+;  STATUS      any                     trashed
+;  all others  any                     preserved
+; Not for use in High ISR
+       mov_ff  FSR0L, dsave_fsr0
+       mov_ff  FSR0H, dsave_fsr0+1
+       mov_lfsr debug, 0
+       mov_ff  debugp, FSR0L
+       mov_wf  INDF0
+       inc_f   debugp
+       mov_ff  dsave_fsr0,   FSR0L
+       mov_ff  dsave_fsr0+1, FSR0H
+       return
+
   include final.inc
index 714269c0fc368c09d78545721ce20434579b0533..6ea0d8571667efee9c1eaac20727acf1f73016f2 100644 (file)
@@ -71,6 +71,7 @@ intrl_handled_routine @
 ;----------------------------------------
 master_init
 ; Master-specific initialisation.
+       call    memory_erase
        call    serial_init
        call    i2cm_init
        call    serialtxbuf_init