EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Clearing RAM in PIC18Fxxx

Started by PigPOg October 15, 2007
I'm trying to clear RAM (to 00 hex) in Bank 0, registers 00 -> 7F
only. But the program only clears up to register 48 hex. I must be
doing something wrong. Can anyone advise please? Thanks, Simon.

;
;	Clear RAM 00 -> 7FH
;	Program only uses BANK0 registers
;
	 CLRF   BSR         ;Ensure working in Bank0.
	 LFSR   FSR0,0x000  ;Initiate to RAM loc. 0
BUMP_RAM CLRF   POSTINC0    ;Clear INDF & increment.
	 BTFSS  FSR0H,0     ;All done in Bank0?
	 GOTO   BUMP_RAM
On Oct 15, 5:30 pm, PigPOg <si...@capella.co.uk> wrote:
> I'm trying to clear RAM (to 00 hex) in Bank 0, registers 00 -> 7F > only. But the program only clears up to register 48 hex. I must be > doing something wrong. Can anyone advise please? Thanks, Simon. > > ; > ; Clear RAM 00 -> 7FH > ; Program only uses BANK0 registers > ; > CLRF BSR ;Ensure working in Bank0. > LFSR FSR0,0x000 ;Initiate to RAM loc. 0 > BUMP_RAM CLRF POSTINC0 ;Clear INDF & increment. > BTFSS FSR0H,0 ;All done in Bank0? > GOTO BUMP_RAM
a) CLRF BSR is unnecessary b) Simulating in MPLAB the above code clears up to 0xFF, as expected. Rocky
On Mon, 15 Oct 2007 11:05:58 -0700, Rocky <RobertGush@gmail.com>
wrote:

>On Oct 15, 5:30 pm, PigPOg <si...@capella.co.uk> wrote: >> I'm trying to clear RAM (to 00 hex) in Bank 0, registers 00 -> 7F >> only. But the program only clears up to register 48 hex. I must be >> doing something wrong. Can anyone advise please? Thanks, Simon. >> >> ; >> ; Clear RAM 00 -> 7FH >> ; Program only uses BANK0 registers >> ; >> CLRF BSR ;Ensure working in Bank0. >> LFSR FSR0,0x000 ;Initiate to RAM loc. 0 >> BUMP_RAM CLRF POSTINC0 ;Clear INDF & increment. >> BTFSS FSR0H,0 ;All done in Bank0? >> GOTO BUMP_RAM > >a) CLRF BSR is unnecessary >b) Simulating in MPLAB the above code clears up to 0xFF, as expected. >Rocky
Removed CLRF BSR, re-compiled and run. Still only clears up to 48H inclusive! Now I'm really confused. Simon
On Tue, 16 Oct 2007 08:28:54 +0100, PigPOg <simon@capella.co.uk>
wrote:

>On Mon, 15 Oct 2007 11:05:58 -0700, Rocky <RobertGush@gmail.com> >wrote: > >>On Oct 15, 5:30 pm, PigPOg <si...@capella.co.uk> wrote: >>> I'm trying to clear RAM (to 00 hex) in Bank 0, registers 00 -> 7F >>> only. But the program only clears up to register 48 hex. I must be >>> doing something wrong. Can anyone advise please? Thanks, Simon. >>> >>> ; >>> ; Clear RAM 00 -> 7FH >>> ; Program only uses BANK0 registers >>> ; >>> CLRF BSR ;Ensure working in Bank0. >>> LFSR FSR0,0x000 ;Initiate to RAM loc. 0 >>> BUMP_RAM CLRF POSTINC0 ;Clear INDF & increment. >>> BTFSS FSR0H,0 ;All done in Bank0? >>> GOTO BUMP_RAM >> >>a) CLRF BSR is unnecessary >>b) Simulating in MPLAB the above code clears up to 0xFF, as expected. >>Rocky > >Removed CLRF BSR, re-compiled and run. Still only clears up to 48H >inclusive! Now I'm really confused. > >Simon
Replied rather hastily. Found the problem, thanks Rocky. Simon
"PigPOg" <simon@capella.co.uk> wrote in message 
news:4kq8h39mna487a1fno10tmcpgeodsdoojg@4ax.com...
> On Tue, 16 Oct 2007 08:28:54 +0100, PigPOg <simon@capella.co.uk> > wrote: > >>On Mon, 15 Oct 2007 11:05:58 -0700, Rocky <RobertGush@gmail.com> >>wrote: >> >>>On Oct 15, 5:30 pm, PigPOg <si...@capella.co.uk> wrote: >>>> I'm trying to clear RAM (to 00 hex) in Bank 0, registers 00 -> 7F >>>> only. But the program only clears up to register 48 hex. I must be >>>> doing something wrong. Can anyone advise please? Thanks, Simon. >>>> >>>> ; >>>> ; Clear RAM 00 -> 7FH >>>> ; Program only uses BANK0 registers >>>> ; >>>> CLRF BSR ;Ensure working in Bank0. >>>> LFSR FSR0,0x000 ;Initiate to RAM loc. 0 >>>> BUMP_RAM CLRF POSTINC0 ;Clear INDF & increment. >>>> BTFSS FSR0H,0 ;All done in Bank0? >>>> GOTO BUMP_RAM >>> >>>a) CLRF BSR is unnecessary >>>b) Simulating in MPLAB the above code clears up to 0xFF, as expected. >>>Rocky >> >>Removed CLRF BSR, re-compiled and run. Still only clears up to 48H >>inclusive! Now I'm really confused. >> >>Simon > > Replied rather hastily. Found the problem, thanks Rocky.
What was the problem?
On Tue, 16 Oct 2007 09:04:52 +0100, "Tom Lucas"
<news@REMOVE_tlcs_THIS_dot_TO_fsnet_REPLY_dot_co.uk> wrote:

>"PigPOg" <simon@capella.co.uk> wrote in message >news:4kq8h39mna487a1fno10tmcpgeodsdoojg@4ax.com... >> On Tue, 16 Oct 2007 08:28:54 +0100, PigPOg <simon@capella.co.uk> >> wrote: >> >>>On Mon, 15 Oct 2007 11:05:58 -0700, Rocky <RobertGush@gmail.com> >>>wrote: >>> >>>>On Oct 15, 5:30 pm, PigPOg <si...@capella.co.uk> wrote: >>>>> I'm trying to clear RAM (to 00 hex) in Bank 0, registers 00 -> 7F >>>>> only. But the program only clears up to register 48 hex. I must be >>>>> doing something wrong. Can anyone advise please? Thanks, Simon. >>>>> >>>>> ; >>>>> ; Clear RAM 00 -> 7FH >>>>> ; Program only uses BANK0 registers >>>>> ; >>>>> CLRF BSR ;Ensure working in Bank0. >>>>> LFSR FSR0,0x000 ;Initiate to RAM loc. 0 >>>>> BUMP_RAM CLRF POSTINC0 ;Clear INDF & increment. >>>>> BTFSS FSR0H,0 ;All done in Bank0? >>>>> GOTO BUMP_RAM >>>> >>>>a) CLRF BSR is unnecessary >>>>b) Simulating in MPLAB the above code clears up to 0xFF, as expected. >>>>Rocky >>> >>>Removed CLRF BSR, re-compiled and run. Still only clears up to 48H >>>inclusive! Now I'm really confused. >>> >>>Simon >> >> Replied rather hastily. Found the problem, thanks Rocky. > >What was the problem? >
I had the wrong Watch window open. Whoops.
"PigPOg" <simon@capella.co.uk> wrote in message 
news:20l9h3hg7i9o068q6dbgt8e5cosqv8htmk@4ax.com...
> On Tue, 16 Oct 2007 09:04:52 +0100, "Tom Lucas" > <news@REMOVE_tlcs_THIS_dot_TO_fsnet_REPLY_dot_co.uk> wrote: > >>"PigPOg" <simon@capella.co.uk> wrote in message >>news:4kq8h39mna487a1fno10tmcpgeodsdoojg@4ax.com... >>> On Tue, 16 Oct 2007 08:28:54 +0100, PigPOg <simon@capella.co.uk> >>> wrote: >>> >>>>On Mon, 15 Oct 2007 11:05:58 -0700, Rocky <RobertGush@gmail.com> >>>>wrote: >>>> >>>>>On Oct 15, 5:30 pm, PigPOg <si...@capella.co.uk> wrote: >>>>>> I'm trying to clear RAM (to 00 hex) in Bank 0, registers 00 -> 7F >>>>>> only. But the program only clears up to register 48 hex. I must >>>>>> be >>>>>> doing something wrong. Can anyone advise please? Thanks, Simon. >>>>>> >>>>>> ; >>>>>> ; Clear RAM 00 -> 7FH >>>>>> ; Program only uses BANK0 registers >>>>>> ; >>>>>> CLRF BSR ;Ensure working in Bank0. >>>>>> LFSR FSR0,0x000 ;Initiate to RAM loc. 0 >>>>>> BUMP_RAM CLRF POSTINC0 ;Clear INDF & increment. >>>>>> BTFSS FSR0H,0 ;All done in Bank0? >>>>>> GOTO BUMP_RAM >>>>> >>>>>a) CLRF BSR is unnecessary >>>>>b) Simulating in MPLAB the above code clears up to 0xFF, as >>>>>expected. >>>>>Rocky >>>> >>>>Removed CLRF BSR, re-compiled and run. Still only clears up to 48H >>>>inclusive! Now I'm really confused. >>>> >>>>Simon >>> >>> Replied rather hastily. Found the problem, thanks Rocky. >> >>What was the problem? >> > > I had the wrong Watch window open. Whoops.
That'll do it every time!

Memfault Beyond the Launch