AUTOSAR Code Generator always writes True to Boolean variable at the time of Initialization

2 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 7 Aug 2020
Simulink prevents writing 0 / false at the time of initialization for AUTOSAR because the initialization of the output block depends on the Real Time Environment (RTE).
Hence, a setting in Code Generation pane (optimization) of Configuration parameters in Simulink, known as "zeroExternalMemoryAtStartup" is checked by default for autosar.tlc.
This setting removes root level I/O zero initialization.This can not be unchecked in "autosar.tlc". It can be unchecked in "ert.tlc".
Hence, the generated code always assumes that variable to be True. There is no current workaround available to change this behavior and that is expected.
However, In this case, the data byte is getting assigned with 1, because the data range of the output variable of the MATLAB function(data) is set to (1 - TxTPMsgBufferSize).
Since NFCControlReq.Enable is of type boolean and is assigned to a variable of whose range is > 1, the generated code gets optimized by assigning the value to 1.
One can avoid this by making a change for the output of the MATLAB function block.
You can refer to "datarangechange.jpg" to view the change to be done. I am also attaching "working_model.zip" file for your reference. (attached in case files)

More Answers (0)

Categories

Find more on AUTOSAR Blockset in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!