2 Replies Latest reply on Mar 28, 2014 7:30 AM by DaKn_263916

    Creator error ?


      I just worked on a forum program for a PSOC 5LP part, that had the


      following declaration in it (as a local to main() )-




          int16 sinresult[19200],cosresult[19200];




      That computes to more SRAM than in part. Program compiled  and reported




      Flash used: 22352 of 262144 bytes (8.5 %).
      SRAM used: 20965 of 65536 bytes (32.0 %).




      Looks like PSOC manufactures SRAM at runtime




      So how does user know he has a real workable code base ?




      Regards, Dana.

        • 1. Re: Creator error ?

          Since the arrays are local to main() their storage class is "automatic" which means they will be allocated at run-time and so the error will appear at run-time, not earlier.It would make a difference when the arrays were declared as "static" or as a global variable (yes, Dana ) which's default storage class would be "static", too. Then the error would be seen at link-time.


          To dwelve deeper: automatic variable allocation usually (and with GCC always) works by allocating room on the stack. So at function entry (remember: main() IS a function) the current stackpointer (sp) is saved, then the amount of needed memory space subtracted from sp. When this underflows or rather exceeds the amount of stack reserved an error is thrown.


          So there is rarely a chance to get informed at link-time of an error like this one





          • 2. Re: Creator error ?

            Bob thanks for the clarification.  Looks like this application is headed for unknown instruction space


            at warp speed.




            Proud of you for using the word Global, I know that was difficult.......




            Regards, Dana.