From c233557943a58a266dda607b68d35fc8887a3416 Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 30 Dec 2005 12:15:40 +0000 Subject: [PATCH] memory erase on master's startup --- detpic/misc.asm | 59 +++++++++++++++++++++++++++++++++++++++++++++- detpic/program.asm | 1 + 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/detpic/misc.asm b/detpic/misc.asm index ad57696..5076592 100644 --- a/detpic/misc.asm +++ b/detpic/misc.asm @@ -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 diff --git a/detpic/program.asm b/detpic/program.asm index 714269c..6ea0d85 100644 --- a/detpic/program.asm +++ b/detpic/program.asm @@ -71,6 +71,7 @@ intrl_handled_routine @ ;---------------------------------------- master_init ; Master-specific initialisation. + call memory_erase call serial_init call i2cm_init call serialtxbuf_init -- 2.30.2