PIC12F675 RAM getting full; will Stack conflict

Discussion in 'Embedded Systems and Microcontrollers' started by aamirali, Sep 9, 2014.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    PIC12F675 have only 64 bytes of RAM.
    I am writing a code. Now RAM had reached around 55 bytes.

    1. Now I am worrying that will stack conflict with it.

    2. I don't know how to check size of stack & will it conflict with RAM.

    3. Can I use entire 64 bytes of RAM without issue with RAM.

    4. I am using MPLAB & Hi0tech C compiler PRO mode.
    Is there any way I can reduce the burden from RAM & put variables into flash/eeprom. Since the application is not very time critical.

    5. PS: I have to try to complete this application in this MCU only. So plz don't suggest take another MCU. Will take another path only in last
  2. takao21203

    AAC Fanatic!

    Apr 28, 2012
    where is the point without showing the code?
    PICs normally use a hardware stack. Or dont you know that?

    And yes you can put some variables as global tough it can be errorprone if you are not used to it.

    Without posting the code your questions are not possible to answer.
  3. tshuck

    Well-Known Member

    Oct 18, 2012
    The stack is different from RAM - the stack is implemented in hardware (sometimes, it's as simple as some reserved memory) and is used for remembering data when jumping around the program memory and some math operations.

    RAM is used like a scratch piece of paper, where you store results and intermediate steps.

    1. There should be no problems with the stack unless you do many function calls, but your compiler should alert you (throw an error) if you exceed the stack length.

    2. Look at your compiler output.

    3. Probably, but the compiler will typically reserve some RAM for its use.

    4. There are ways to do this, but you are then putting wear on the EEPROM...
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    Depending on the PIC and the compiler the hardware stack may be replaced by a soft stack in RAM. Either way if you build the project and get a good build it fit in your device. mPLAB has a tool to show how much RAM and ROM have been used (IF the project builds).

    That device has some 128 bytes of EEPROM you can use in addition to ram. You are limited to one million write cycles so use them wisely for things that dairy change.
  5. JohnInTX


    Jun 26, 2012
    Also, use const to put any constant values (segment tables,etc) into ROM. Otherwise the compiler will make them initialized RAM ...depending on the compiler but my old version of hitech works this way. Look at the .map file to see what storage class is used for variables, constants.

    Good luck.