Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
2 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes