16F886 running out of SRAM ?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    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).

  2. #2


    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