10F222 ADRES as one more VAR?


Closed Thread
Results 1 to 9 of 9
  1. #1

    Default 10F222 ADRES as one more VAR?

    I was a bit surprised to find that I only have three bytes of RAM to work with in the 10F222. If I had read more carefully I would have caught the part about PICBasic Pro claiming most of the RAM. I've managed pretty well using just those three bytes but now I really need just one more.

    Since I am not using the ADC's is there any harm in using ADRES as a variable? The code compiles just fine but I have not run it yet.

    Rich

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    As long as it doesn't adversely impact on the way the PIC is configured and run, you could use any Register as storage or as a variable.

    I remember an old long retired IT Manager telling me when as a 'New Boy' starting as a junior, he spent a WEEK looking for a spare BIT that could be used in the company's IBM Mainframe Payroll Program which had filled all of the available 8K Memory! My, how times have changed!

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks, I thought it might work.

    Also, if I read the datasheet correctly, ADRES retains it's value when rebooted. That would be really useful, just so long as it can't get worn out from being used constantly.

    Rich H

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Boy Howdy,
    I LIKE it when people think "outside the box", cause when they share it the box just gets bigger.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I don't think ADRES will work (should have checked yesterday)... pick a different register. Woke up this morning with something bugging me about your choice... according to the Datasheet ADRES is READ ONLY.

  6. #6
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    I would look at the LST file to see which variables PBP is not using; just allocating. Let me explain

    If you look at pause or maybe pauseus, you will see that PBP uses the R0 and R1 registers each WORD type to handle the delay function. Similarly, PBP uses variables T1 to T4 for Boolean arithmetic (I deduced this by looking at the lst file). You can salvage some RAM by breaking up logical ANDs to a nested if structure - something like this

    Code:
         ' typical logical and
         if  testcondition1 and testcondition2 then
                 do something
         endif
    
         ' typical logical or
         if testcondition3 or testcondition4 then
                 do somethingelse
         endif
    can be changed to
    Code:
         ' simplified logical and
         if testcondition1 then
              if testcondition2 then
                    do something
              endif
         endif
    
         ' simplified logical OR
         if testcondition3 then dosomethingelse
         if testcondition4 then dosomethingelse
    the second structure does not involve the T1..T4 variables of PBP and is resource friendly.

    Hopefully not using the logical operations of PBP will let PBP yeild the T1 to T4 registers???

    A look into the Listing file will yeild some more. I haven't gone into the details yet.
    Last edited by Jerson; - 10th May 2010 at 10:14. Reason: added stuff

  7. #7


    Did you find this post helpful? Yes | No

    Default No go for using ADRES :(

    Okay, I guess that explains why I couldn't get my program working, would have been nice to use ADRES.

    As far as the booleans, I cannot use them now without getting the "unable to fit variable" error.

    I currently use one word sized and one byte sized variable.

    When I look at the list file I see that R2 and R3 are not used. Does that mean I can do something like;
    Code:
    NewVariable  VAR   R2
    New approach, I set OPTION_REG.5 = 1 so that TMR0 would not increment and I am using that for my missing byte. It is working so far... but if I can use R2 or R3 that would be better because I wanted to try to use TMR0.

    Rich H

  8. #8
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    Looks like you can get by doing that. Try it out!!!

  9. #9
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    With Timer0 clock source set to external, and using TMR0 register as a variable, I would check to make sure TMR0 isn't incrementing when taking GP2 high/low.

    Some internal counters, when configured for external clocks, will increment if you're using the pin as an output & toggling the pin.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts