Use Global Initialization

<< Click to Display Table of Contents >>

Navigation:  Tips & Tricks > Waijung >

Use Global Initialization

Previous pageReturn to chapter overviewNext page

Each Waijung block may have hardware initialization code that set up hardware module before use.

When such Waijung blocks are placed inside a subsystem, e.g. an enable subsystem, the initialization code get executed every time the subsystem is activated.

This behavior allows proper enable/disable synchronization of the hardware modules and the corresponding subsystems.

However, in some cases, where the hardware does not change and there is no need to re-run the initialization code every time, this behavior create unnecessary overhead in the generated code and execution.

The overhead can be avoided by selecting Use Global Initialization option from the Mask parameter (if available).

This setting forces Waijung to place the initialization code at the beginning of the code such that the initialization code runs only once the first time the system starts.

For example see the demo file waijungroot\targets\stm32f4_target\stm32f4\demo\digital_output_demo\stm32f4_digital_output_subsystem_demo.mdl below.

This demo shows standard behavior where the Digital Output Block is placed under an enabled subsystem.

use_global_init_no

Observer that the initialization code enable_SubsystemDigitalOutput(); is called every time the subsystem is enabled / disabled.

use_global_init_no_code

With the same model, where "Use Global Initialization" checkbox is activated.

use_global_init_yes_mask

Observer now that the initialization code enable_SubsystemDigitalOutput(); is called only once the first time the system starts.

use_global_init_yes_code