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

How to determine the actual usage for XDATA?

Hello,

I have a project with 512K flash for code and 64K SRAM for XDATA. After compiling with PK51, I got following infos about program size:
"data=188.0 xdata=51140 const=166971 code=203033".

My question is: does this mean the MAXIMUM usage for xdata is 51140? Or the actual space for xdata will increase when the code is up and running if there are pointer? How can I calculate the maximum/worst space requirement for xdata?

Any help is appreciated!

Thanks a lot
Henry

Parents
  • "does this mean the MAXIMUM usage for xdata is 51140?"

    It means that the sum of the storage requirements for objects having static storage duration plus the Keil-specific LARGE model (if appropriate for your configuration) data objects having automatic storage duration total to 51140 bytes.

    "Or the actual space for xdata will increase when the code is up and running if there are pointer?"

    That's for you to determine. Memory accesses through pointers are not accounted for by the toolchain.

    "How can I calculate the maximum/worst space requirement for xdata?"

    That's the kind of question that if it's not obvious to you and you have to ask, then we couldn't possibly tell you either.

Reply
  • "does this mean the MAXIMUM usage for xdata is 51140?"

    It means that the sum of the storage requirements for objects having static storage duration plus the Keil-specific LARGE model (if appropriate for your configuration) data objects having automatic storage duration total to 51140 bytes.

    "Or the actual space for xdata will increase when the code is up and running if there are pointer?"

    That's for you to determine. Memory accesses through pointers are not accounted for by the toolchain.

    "How can I calculate the maximum/worst space requirement for xdata?"

    That's the kind of question that if it's not obvious to you and you have to ask, then we couldn't possibly tell you either.

Children
  • Thanks a lot, Dan.

    But how could I detemine if the remaining SRAM(64K - 51K) is enough for code to run? Or how could I determine if some strange issue is casued by the lack of SRAM? Are there tools or hints you could share for diagnosing this kind of issue?

    Why I am asking is becasue I am having some quite strange phenomena which I can not find the root cause. But I think the logical of my code is ok. There are some SRAM consuming protocols in my code.

    Best regards,
    Henry

  • "Are there tools or hints you could share for diagnosing this kind of issue?"

    Tools like lint (e.g., PC-Lint) come to mind.

    "Why I am asking is becasue I am having some quite strange phenomena which I can not find the root cause. But I think the logical of my code is ok. There are some SRAM consuming protocols in my code."

    200K is quite a bit of code for a '51. Why isn't your program's memory usage better understood? Are you the author? Was this program originally designed for an 8051 derivative? If not, the mere fact that an unusual and limited target processor architecture like the 8051 wasn't a design criterion could account for a lot of misbehavior.