User Changes in Generated Code

It's necessary to say at the beginning of the chapter, that modification of the generated code may be done only at user's own risk. Generated code was thoroughly tested by the skilled developers and the functionality of the modified code cannot be guaranteed. We strongly don't recommend modification of the generated code to the beginners. See more information for generated modules in chapter Code Generation.

To support user changes in the bean modules, Processor Expert supports the following features:

1. CH file - manifest constants

Processor Expert automatically produce list of manifest constants for all beans, which encapsulate any CPU peripheral and modifies any of the CPU control registers. The name of each manifest constant is in the following format:

C_[bean+method]_reg_[register name][additional-info]

where

  • [bean+method] is name of bean (and optionally also bean's method),
  • [register name] is name of the control register,
  • [additional-info] is additional information about usage of the value (modification of one bit, bits mask or whole value).

 

These constants may be used to write user code, which reflects the bean settings. Once the constant is generated into the CH file, it is preserved there even it is already not used in the bean module. The most important advantage of these constants is, that small changes in the bean settings (for example timing) does not cause change of the bean module, but the only CH file is changed.

The name of the CH file is derived from the CPU bean name ([CPUbean].CH). To generate CH file it is necessary to set the following option: Project Options | Generate manifest constants. CH file is generated also while smart generation of bean modules code, see paragraph 3 for details. CH file is always overwritten during the code generation.

2. Mode of code generation for bean modules

It's possible to select mode of the code generation for each bean, the following options can be found in the bean's pop-up menu in the project panel:

Code Generation

  • Always Write Generated Bean Modules (default) - generated bean modules are always written to disk and any existing previous module is overwritten
  • Preserve User Changed in Generated Bean Modules - smart detection of user changes. See paragraph 4 for details.
  • Don't Write Generated Bean Modules - the code from bean is not generated. Any initialization code of the bean, which resides in the CPU bean, interrupt vector table and shared modules are updated.

 

The mode of code generation is indicated as a bean's status in the project panel. This mode influences only the generation of bean modules (bean.c, bean.h).

3. Mode of code generation for non-bean modules

Processor Expert also allows to enable/disable generation of the modules that not related to a specific bean or that are common for several beans. This option can be configured in the pop-up menu of the module in the Project Panel. Current enable/disable state of this option is signalled by the icon near the bean module name in the Project Panel ( - enabled, - disabled).

Code Generation
  • Always Write (default) - generated bean modules are always written to disk and any existing previous module is overwritten
  • Don't Write - the content of the module is not overwritten. Please notice that this can lead to malfunction of beans dependent on the module when the module update is required due to bean's settings change.

4. Smart generation of the code of bean modules

Notice: Smart user changes preservation is available only in the 56F800/E version.

To enable smart generation of the bean modules, it's necessary to set the project option Project Options | Preserve user changes. (option Project Options | Generate manifest constants is turned on automatically). After setting this option it's necessary to generate the code and after that Processor Expert can detect and preserve changes in the generated code of bean modules. In this mode it is still possible to select for each bean, if the code will be overwritten, not written or if the user changes will be preserved (see paragraph 2). In case of first use of the bean, the generated code will be always overwritten.
The user can make any change in the generated bean module. If the Processor Expert detects during code generation, that the bean module was changed, the user is informed immediately. Status icon of the bean with changed module is red . Until the generated code is not changed, the user changes are completely preserved.

The generated code of the bean module may be changed from several reasons:

  • the user changed the bean settings
  • the user changed settings of another bean, and the change is reflected to the bean's module
  • the bean driver was changed (updated)

 

The following changes in the generated code may be updated automatically into the bean's module:

  • new method is generated into the bean's module - this method is automatically added into the bean's module
  • any method from the bean's module is not generated - if the method code is not changed in the user code, the method is automatically removed from the bean's module.
  • If the code of the generated method has changed and it wasn't changed by the user, the code of method is automatically updated.

 

In all other cases the user must select how to handle the changed code (see the following picture):

  • Don't overwrite the bean module (default) - the user changes are preserved and the generated code is ignored
  • Overwrite the bean module - the user changes are discarded and the user module is rewritten by the new generated code
  • Never overwrite all the bean modules - the mode of the code generation for the bean is "Don't Write Generated Code", see paragraph 2 for details
  • Always overwrite all the bean modules - the mode of the code generation for the bean is "Always Write Generated Code", see paragraph 2 for details
  • Always overwrite all modules (turn off smart generation) - smart generation of the code if switched off, all user modules are overwritten.

 

 

Figure 1 - User Changes Handling Options

Viewing User Changes in a Bean Module

The user changes done in a bean module or bean header module can be viewed using a bean pop-up menu commands Compare With Previously Generated Module and Compare With Previously Generated Header Module. See chapter Beans Pop-up Menus for details. The user can also enable reviewing all changes done into the generated code after each code generation. See chapter Tracking Changes in Generated Code for details.


 

 

[top of page]