MicroC Code Generator : Code Options : Setting the Time Scale : Setting the Time Expression Scale

Setting the Time Expression Scale

Once the user has used a counter in the model, and selected “Time Expression Scale” other than “Counter Ticks”, it is required that the “Time Expression Scale” in the Rational Statemate MicroC Profile be filled in. Each counter has three fields:

counter name: The name of the referenced counter
ticks per second: The number of ticks the counter counts per second
ticks per milli-second: The number of ticks the counter counts per milli-second.

Note that the fields “ticks per second” and “ticks per milli-second” don’t have to be both defined, nor does the ratio between their definitions have to be 1000.

If some necessary data is missing from the “Time Expression Scale,” the Code Generator will issue a warning message.

In the OSI: “MAINLOOP_SC” there are two predefined counters “ms_counter”, and “sec_counter”. Default values are already filled in the “Time Expression Scale Table” for these counters.

If the model does not use the seconds/milliseconds as the “Time Expression Scale”, then these definitions are not required.

When converting to code, the “Time Expression” is automatically scaled to ticks according to the current “Time Expression Scale”:

Counter's Ticks: Nothing is changed - Use the time expression as in model.
Seconds: Multiply the time expression with the following macro:

“<counter>_TICKS_PER_SEC”
Milli - Seconds: Multiply the time expression with the following macro:

“<counter>_TICKS_PER_MSEC”