16F886 running out of SRAM ?


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

    Default 16F886 running out of SRAM ?

    I have ported a project from the 16F690 to the 16F886 to gain more memory codespace, and have benefitted form getting more ram too.

    The datasheet says I have over 300 bytes of SRAM, but as I've got to about my 70th byte of ram I have started to get problems with the chip stopping.

    I have an assembly interupt running (well established code I've used many times), the code enters the interupt, resets the one second flag properly and exits cleanly, but ponly on the first interupt, thereafter it crashes.

    Are there any issues with accessing the whole ram codespace ? Am I missing something like as if I should be taking responsibility for bank switching and so on.

    I had a similar thing happen to me with a pic which had 128 bytes of ram, I ran out of variables at about 70 or 80 (due to the pbp overhead) but didn't expect to run out so soon with over 300 bytes of sram.

    I would appreciate any help with this because I'm really stuck.

    The reason I need so many variables is because I'm doing a lot with arrays/scrolling messages and menu items on a 2x16 lcd running a menu system, so there's lot's of pointers and screen maps etc. required

    Thanks in advance
    Chris

  2. #2
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    I have moved this post to a new thread in the "Off-topic" forum as it is somewhat off-topic.
    Last edited by rmteo; - 29th August 2008 at 05:47. Reason: - moved to "Off-topic" forum.

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


    Did you find this post helpful? Yes | No

    Default

    * * * * No Fire Suit Required * * * *
    The opinions expressed above are a welcome dissertation by their author.
    * * * * Only problem I see is 24 series PIC <> supported in PBP * * * *
    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.

  4. #4
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    MicroChip does offer a free C compiler. If you are a BASIC afficionado (like myself), mikroElectronika do have a BASIC compiler for the PIC24 and dsPIC30/33.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rmteo View Post
    I have moved this post to a new thread in the "Off-topic" forum as it is somewhat off-topic.


    No yopu mean you appear to have deleted it, because it isn't in the off-topic forum......either way, any idea what the problem may be ?

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


    Did you find this post helpful? Yes | No

    Default

    Check your code. You may have a jump back from your ISR instead of a RESUME. You might have a jump out of a subroutine instead of a RETURN. Whole heaps of minor things like this which are easily missed can cause your program to crash unexpectedly.

    If you run out of RAM, the Compiler will tell you at compile time that you've used up all you're allocated, so it leads me to suspect you're doing something illegal in your code...

    Since you're using arrays a typical mistake is to allocate say 64 bytes of RAM for an array...

    MyArray var Byte (64)

    ... and then trying to modify MyArray(64) forgetting that the legal count is from 0-63, and byte numbered 64 (which you can access) does not belong to your array.

    CHeck IF/THEN statements that access arrays are counting within the legal limit and not accessing bytes outside the defined array.

    On the plus side, I have code that uses large amount of RAM on various 16F and 18F parts without issues (though not on that particular chip you've mentioned).

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    Check your code. You may have a jump back from your ISR instead of a RESUME. You might have a jump out of a subroutine instead of a RETURN. Whole heaps of minor things like this which are easily missed can cause your program to crash unexpectedly.

    If you run out of RAM, the Compiler will tell you at compile time that you've used up all you're allocated, so it leads me to suspect you're doing something illegal in your code...

    Since you're using arrays a typical mistake is to allocate say 64 bytes of RAM for an array...

    MyArray var Byte (64)

    ... and then trying to modify MyArray(64) forgetting that the legal count is from 0-63, and byte numbered 64 (which you can access) does not belong to your array.

    CHeck IF/THEN statements that access arrays are counting within the legal limit and not accessing bytes outside the defined array.

    On the plus side, I have code that uses large amount of RAM on various 16F and 18F parts without issues (though not on that particular chip you've mentioned).


    Thanks for the reply

    I've stripped back everything from the code to just the ISR (assembly) and the code which checks for a 1 second epoch (flag is set during ISR)

    I can add lots more vars now, so presumably something is wrong with my structuring which I'll have to work on by reintroducing the other subr's one at a time, but at least that's a start.

    I'm also using both pwm output channels independently of one another, a 2 x 16 lcd display and a rotary encoder so I've missed a step of something out I reckon !

    Best Wishes
    Chris

Similar Threads

  1. Problem with connection to SPI SRAM 23K256
    By hankshone in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 27th September 2014, 02:58
  2. pic first build test board not running
    By comwarrior in forum Schematics
    Replies: 11
    Last Post: - 29th June 2009, 16:48
  3. 16f886
    By hvacrtech in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 27th May 2008, 05:06
  4. PIC Basic Pro Ver 2.47 Can't Do 16F886
    By NO2K in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th April 2008, 19:02
  5. I’m Running Out of CodeSpace, What Can I Do?
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 12th July 2004, 19:25

Members who have read this thread : 0

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

Posting Permissions

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