Skip to main content

Code generation

The Device Configurator generates structures, defines, and initialization code for the blocks on the chip. All generated code is located in the GeneratedSource folder next to the *.modus file. Refer to the Peripheral Driver Library (PDL) API Reference for more information about this code. Each enabled resource has a link to the specific driver documentation in the Parameters pane.

note

The Device Configurator generates code based on the hardware resources that are enabled. If a resource is not enabled, no configuration will be generated for it. This means the resource will retain its default reset state. In most cases, this is powered off. However, some features are enabled by default, such as debug connectivity. To disconnect these features, you must call the appropriate API functions to turn the feature off.

The defines and structures are all named based on the resource that created it. In general, these have the form [resource-name]_config. These structures can be passed to the PDL functions that are responsible for configuring the hardware block.

The functions are specific to a resource category and have names of the form init_cycfg_[resource-category]. The init function for a particular resource type is located in GeneratedSource/cycfg_[resource-category].h. There are also the cycfg.h and cycfg.c files. Include the cycfg.h file in your application to access the generated header files. The cycfg.c file implements init_cycfg_all(), which calls all other generated functions, for example init_cycfg_pins().

The resource types include:

  • Clocks: Peripheral clocks

  • Connectivity: Configuration of the programmable analog and digital routing resources

  • Peripherals: Fixed function analog and digital peripherals

  • System: Overall configuration function to setup all power and clock options

It is up to you to make use of the generated code based on the application's needs. This can be done as part of the application’s main() loop.