SFR's as RAM ?

View: New views
11 Messages — Rating Filter:   Alert me  

SFR's as RAM ?

by PICdude-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Other than being bad form, are there any problems with using SFR's  
such as ADRESH and ADRESL for some temporary RAM space (assuming the  
ADC is off)?

Cheers,
-Neil.


--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: SFR's as RAM ?

by Jinx-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey Neil

> Other than being bad form, are there any problems with using SFR's  
> such as ADRESH and ADRESL for some temporary RAM space
> (assuming the ADC is off)?

ISTR Microchip suggest using unaccessed SFRs as general purpose
RAM in the datasheet. 'bad form' can manifest itself in many ways if
you don't know what you're doing or don't pay attention ;-)

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

RE: SFR's as RAM ?

by Michael Rigby-Jones-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



> -----Original Message-----
> From: piclist-bounces@... [mailto:piclist-bounces@...] On
Behalf

> Of Jinx
> Sent: 29 October 2009 08:54
> To: Microcontroller discussion list - Public.
> Subject: Re: [PIC] SFR's as RAM ?
>
> Hey Neil
>
> > Other than being bad form, are there any problems with using SFR's
> > such as ADRESH and ADRESL for some temporary RAM space
> > (assuming the ADC is off)?
>
> ISTR Microchip suggest using unaccessed SFRs as general purpose
> RAM in the datasheet. 'bad form' can manifest itself in many ways if
> you don't know what you're doing or don't pay attention ;-)

The HiTech compiler uses some SFRs for temporary storage if they aren't
being used.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

RE: SFR's as RAM ?

by PICdude-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well this is good to know.

Jinx: of course I always know what I'm doing ... at least until  
something smokes.

Cheers,
-Neil.


Quoting Michael Rigby-Jones <Michael.Rigby-Jones@...>:

>
>
>> -----Original Message-----
>> From: piclist-bounces@... [mailto:piclist-bounces@...] On
> Behalf
>> Of Jinx
>> Sent: 29 October 2009 08:54
>> To: Microcontroller discussion list - Public.
>> Subject: Re: [PIC] SFR's as RAM ?
>>
>> Hey Neil
>>
>> > Other than being bad form, are there any problems with using SFR's
>> > such as ADRESH and ADRESL for some temporary RAM space
>> > (assuming the ADC is off)?
>>
>> ISTR Microchip suggest using unaccessed SFRs as general purpose
>> RAM in the datasheet. 'bad form' can manifest itself in many ways if
>> you don't know what you're doing or don't pay attention ;-)
>
> The HiTech compiler uses some SFRs for temporary storage if they aren't
> being used.
>
> Regards
>
> Mike
>
> =======================================================================
> This e-mail is intended for the person it is addressed to only. The
> information contained in it may be confidential and/or protected by
> law. If you are not the intended recipient of this message, you must
> not make any use of this information, or copy or show it to any
> person. Please contact us immediately to tell us that you have
> received this e-mail, and return the original to us. Any use,
> forwarding, printing or copying of this message is strictly prohibited.
> No part of this message can be considered a request for goods or
> services.
> =======================================================================
>
> --
> http://www.piclist.com PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>




--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: SFR's as RAM ?

by Bob Axtell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Other than being bad form, are there any problems with using SFR's
> such as ADRESH and ADRESL for some temporary RAM space (assuming the
> ADC is off)?
>
> Cheers,
> -Neil.
>
Nope. I almost always use up TMR2, TIMER1, PR2, ADRESL. I think ADRESH is
less than 8 bits. I've even used SBRGH (sp?) sometimes when I don't need a
serial port.

Another uncommon use for SFR's is that when you are writing code for
slight variants (PIC16F876A vs PIC16F877A) I test different SFRs to
determine what processor is running, so I can know about analog, port
availability, etc. That way, the code can be universal with slight
different branches in the code.

--Bob

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Parent Message unknown Re: SFR's as RAM ?

by Charles Craft :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----Original Message-----
>From: Bob Axtell <engineer@...>
>Sent: Oct 29, 2009 6:04 PM

>
>Another uncommon use for SFR's is that when you are writing code for
>slight variants (PIC16F876A vs PIC16F877A) I test different SFRs to
>determine what processor is running, so I can know about analog, port
>availability, etc. That way, the code can be universal with slight
>different branches in the code.
>
>--Bob

When/how do you test a SFR?
Pre-processor, compiler, linker, runtime?


--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: SFR's as RAM ?

by Dario Greggio (in giro) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Charles Craft ha scritto:

> When/how do you test a SFR?
> Pre-processor, compiler, linker, runtime?
>
>

I suppose runtime, in this case...
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: SFR's as RAM ?

by Tamas Rudnai :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 30, 2009 at 1:00 AM, Dario Greggio <adpm.to@...> wrote:
>> When/how do you test a SFR?
>> Pre-processor, compiler, linker, runtime?
>>
>
> I suppose runtime, in this case...

Does it mean that the binary (compiled code) can run on many different
PIC? I suppose the variation of the target would be quite limited
anyway?

Tamas
--
/* www.mcuhobby.com */ int main() { char *a,*s,*q; printf(s="/*
www.mcuhobby.com */ int main() { char *a,*s,*q; printf(s=%s%s%s,
q=%s%s%s%s,s,q,q,a=%s%s%s%s,q,q,q,a,a,q); }",
q="\"",s,q,q,a="\\",q,q,q,a,a,q); }
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: SFR's as RAM ?

by Dario Greggio (in giro) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Tamas Rudnai ha scritto:
> On Fri, Oct 30, 2009 at 1:00 AM, Dario Greggio <adpm.to@...> wrote:
>>> When/how do you test a SFR?
>>> Pre-processor, compiler, linker, runtime?
>>>
>> I suppose runtime, in this case...
>
> Does it mean that the binary (compiled code) can run on many different
> PIC? I suppose the variation of the target would be quite limited
> anyway?

yes, indeed I agree...
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: SFR's as RAM ?

by Barry Gershenfeld-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> > Does it mean that the binary (compiled code) can run on many different
> > PIC? I suppose the variation of the target would be quite limited
> > anyway?
>

Remember that the instruction sets across a PIC family (PIC16F, for example)
are identical.  That means that from chip to chip, it's the peripherals that
may or may not be there.

Probably the most extreme example of this reuse thing is in the 18F chips,
where unused USB buffers can be used as RAM, and there are several K bytes
of space there.
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: SFR's as RAM ?

by Ruben Jönsson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> Probably the most extreme example of this reuse thing is in the 18F chips,
> where unused USB buffers can be used as RAM, and there are several K bytes
> of space there.
> --

Anoter way to get "free ram" is if you use a character LCD. The controller
always has DDRAM for 4*20 characters even if the display has less. Unused (not
visible) character positions can be used as RAM. Only remember to not use
instructions that affects all DDRAM, like Clear Display.

/Ruben

==============================
Ruben Jönsson
AB Liros Electronic
Box 9124, 200 39 Malmö, Sweden
TEL INT +46 40142078
FAX INT +46 40947388
ruben@...
==============================

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist