We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi all, I have written a complex program (CAN higher layer protocol driver ),which has many "for" loops and lots of calls.But after ceratin number of calls the stack reaches 37 :1F and then on the program hangs ..I tried defining as much of global variables ,passing less parameters , overlaying etc .. but when theres a "for" loop of just @4 or 5 iterations , the stack problem comes .. what are the possible options to avoid this from happening ? regards sameer
HI Thanks! There is nothing in the "for" loop thats messing up the stack also there were no linker warnings.,.. but why should the problem should disappear once the for loop commented out ? few points :1>here was another for loop inside a for loop .. total iterations were 108 .. another question is for initiailization of some XRAM in infineon 505 , i am calling certain driver routines , which access only the XDATA .. through ptrs which i pass them through reference. now when i call this routine more than 3 times consecutively , the stack over flows !! (this is in the simulation itself ),but for less than 3 times , theres no problem in the stack .. and the complete program works fine .. this has put a very irritating limiation on the no of message objects i can use for CAN communication. regards sameer
"access only the XDATA .. through ptrs" Are you sure that they're accessing XDATA? - use the debugger to verify that the pointers really are pointing to XDATA. With C51, your pointers need to specify not only the correct address, but also the correct memory space (CODE, DATA, IDATA, PDATA, XDATA). Therefore, if you have a bad pointer it could be pointing to the wrong address, or the wrong memory space, or both!!
Using the simulator, you can check that the stack pointer has the same value before and after each call. If it is not, then the call is at fault and needs to be sorted out.