Jump to content

The Classic Memory allocation error.

Recommended Posts

Status Word Memory allocations.

Many of the inbuilt function modules in CScape have a status word requirement/option and this status word typically requires 2 x 16 bit words stored consecutively.


This requires two 16 bit words to be reserved, with the name of the first word specified as the "Address".

The common mistake, is to declare a single word as a global and point to that word only. The operation of the "module" passes data to both the "Address" register and the following register.
If this register has not be reserved, then it can be dynamically allocated as a separate storage register for another variable and errors will occur.

The safest method, is to declare an array of two words.



An alternative method, is to declare two variables at consecutive memory addresses and use the lowest address word as the index.

i.e. SerialStatusA  at %R100 and SerialStatusB at %R101 and use SerialStatusA as the index instead of SerialStatus[0] above.

Look carefully at the requirements. Some statuses require 1 word, others 2 words and some 4 words.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...