This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

stack problem

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

Parents
  • Hi Andrew 1

    Thanks a lot ..
    after carefully looking at the for loop
    i found out .... it was modifying the
    stack !! .....since one of the array of pointers was not initialized properly !!
    and when i was storing something ..to those locations .. i was actually modifying my internal ram ie the stack !!!!

    well this as solved all my problems now !!

    well thanks again for giving me the correct direction !!

    cheers
    sameer



Reply
  • Hi Andrew 1

    Thanks a lot ..
    after carefully looking at the for loop
    i found out .... it was modifying the
    stack !! .....since one of the array of pointers was not initialized properly !!
    and when i was storing something ..to those locations .. i was actually modifying my internal ram ie the stack !!!!

    well this as solved all my problems now !!

    well thanks again for giving me the correct direction !!

    cheers
    sameer



Children
  • Ah, the old Uninitialised Pointer fault.

    This causes plenty of grief with standard 'C', but C51 adds the complication of the different memory spaces:

    The 1st byte of a C51 Generic Pointer specifies the memory space. For an uninitialised pointer, this is likely to be zero - which points into IDATA/DATA/BDATA, so you can soon be pointing into the stack!

    BTW: Unless you really need a Generic Pointers, a Memory-Specific Pointer would be more efficient.
    See the C51 manual