XMC Peripheral Library for XMC4000 Family
Personalities Reference

Personality Introduction

The XMC Peripheral Library includes a set of files to enable the ModusToolbox™ Device Configurator functionality. These files are known as personalities. They describe the GUI to the microcontroller hardware resources for the Device Configurator in the xml format. Each hardware resource of a microcontroller has its own personality.
Based on the user settings, personalities generate initialization code (configuration structures and initialization API calls) executed within the init_cycfg_all() function. The init_cycfg_all() function is usually executed within the cybsp_init() function or may be called directly in the main() function by the user. The system clock personalities generate a strong definition of the SystemCoreClockSetup() function executed at a startup (before jumping to main.c, not within the init_cycfg_all() unlike other ModusToolbox™ PDL products).

For more details, refer to:

Common Groups

The parameters of microcontroller resources are allocated in groups. Most of the personalities have groups named: Documentation, Connections, Advanced.

Documentation
The "Documentation" group displays one or more links to the documentation:
  • API Help: is the link to the application programing interface (API) documentation of the hardware resource to which the current displayed personality is related.
  • Personality Help: is the link to the documentation of the current personality.

Connections
The "Connections" group contains the parameters, which link different personalities and different hardware resources. This way, configurations chains are formed.

Advanced

The "Advanced" group may contain all or one of the listed parameters:

  • Start After Initialization: If enabled, the peripheral will start at the end of the peripheral initialization.
  • Store Config in Flash: Controls whether the configuration structure is stored in flash (const, true) or SRAM (not const, false).

Pin Personality

The pins of the Pin personality for XMC family microcontrollers do not generate service requests. This feature is determined by the hardware architecture of the XMC family.
However, pins can be configured as event resources for the Event Request Unit (ERU), and ERU will generate a service request instead of Pin.

To adjust an Interrupt from a pin (GPIO) requires the adjustments by the configurations chain: Pin - ERU_ERS - ERU_ETL - ERU_OGU/Service Request.

pin_interrupt_config.png

Refer to the ERU Personality section for Interrupt configuration details.
Refer to the API reference General Purpose Input Output (GPIO) for the API details.
Refer to the device Datasheet and Reference Manual for HW details.

ERU Personality

The Event Request Unit (ERU) architecture includes three subunits: Event Request Select (ERS), Event Trigger Logic (ETL), and Output Gating Unit (OGU).
Thus, the ERU personality is represented as the three personalities of the ERU subunits.

For more details, refer to:

ERS Personality

The ERS personality provides a graphical interface to connect a corresponding ERS input channel to a specific event source, to determine the ERS output signal Combination Logic, and to connect an ERS unit with a corresponding ETL unit.

ers_personality_connections.png

After ERS is set, the next step of the ERU adjustment by the configuration chain is configuration of the ETL.

ETL Personality

The ETL personality provides a graphical interface to determine the conditions of incoming signal processing. If the incoming signal satisfies the conditions defined by the "Edge Detection" parameter, the signal is regarded as a true event.
The event generates a trigger, whose distribution path to OGU is also controlled by the parameters of the ETL personality GUI.

etl_personality_connections.png

To continue ERU adjustments, go to the OGU personality configuration by the configuration chain.

OGU Personality.

An OGU unit combines trigger events and status information and gates the Output. The OGU personality provides a graphical interface to determine in which way that will occurs.

Note
The OGU settings may be set so that an event of one Input will lead to reactions on several Outputs.

OGU Outputs may be used as triggers for the other units, for example, to DMA.
An OGU reaction may be setting the service request generation. To enable the service request generation, check the "Pattern Detection" parameter.

ogu_personality_connections.png

Refer to the API reference Event Request Unit (ERU) for the API details.
Refer to the XMC 1000, XMC 4000 Event Request Unit (ERU) Application Note.
Refer to the device Datasheet and Reference Manual for HW details.

ETH Personality

Note
The Ethernet personality has version 0.5 due to the limitations listed below.
These limitations will be removed in version 1.0.

The Ethernet MAC (ETH) personality provides a graphical interface to configure the ETH hardware module.
The settings collected in the ETH Personality GUI allow to configure only part of the consumer's Ethernet application - the physical layer (PHY) and data exchange layer, see the picture below.

eth_persinality_inOSI_model.png

The network and protocol layers, as well as their configuration, must be implemented by the user in their application. The initialization code generated by the ETH personality is a basic template for the user application or for a code example from the manufacturer.

When the ETH Personality connects to a project, an informational message displays in the Notice List pane.

eth_personality_permanentMSG.png

The message reminds the user to make additional settings (global preprocessor #define) for the MTB project after completing the settings in the Device Configurator.
After performing this additional definition, the function call will become available:
XMC_ETH_PHY_Init((XMC_ETH_MAC_t*)&myETH_mac, MyETH_PHY_ADDR, &myETH_phy_config);

The global #define can be made in several ways:

  1. correct the "DEFINES=" string from the "Advanced Configuration" section in "Makefile" located in the root directory of the project.
  2. correct the "BSP_DEFINES:=" string at the beginning of "bsp.mk" located in the "./bsps/TARGET_APP..." directory of the project.
  3. configure the project properties by clicking the project/C++ General Include Path, Macros etc. User Setting Entries).

The ETH personality configurations allow the user to configure the usage of one of the three PHY device drivers included in the XMClib or create their own driver for an alternative PHY device.

The interface between the microcontroller and the PHY device may be configured by the personality settings. This may be either an RMII or MII interface. The RMII interface is always available for configuration, but the MII interface is only available for MCUs with more than 100 pins.

After selecting the “Enable Autonegotiation” and/or “Poll Received Data”, messages display in the Notice List pane to inform the user to implement such functionality on their own.

eth_personality_temporaryMSG.png

The selection of the "Receive Broadcast Frames" and "Enable Promiscuous Mode" options just adds function calls to the generated code without displaying messages for the user.

Note
In addition to the global definition of the PHY device, after completing the ETH Personality settings and code generation by the Device Configurator, it is necessary to additionally initialize the fields (.rx_desc, .tx_desc, .rx_buf, .tx_buf) of the structure myETH_mac.
The correct addresses of declared arrays must be placed in the structure. The arrays must be independently declared by the user and have a separate attribute to place the arrays into the specialized “ETH_RAM” memory section:
static __attribute__((aligned(4))) XMC_ETH_MAC_DMA_DESC_t myETH_MTL_rx_desc[myETH_MTL_NUM_RX_BUF] __attribute__((section ("ETH_RAM")));
static __attribute__((aligned(4))) XMC_ETH_MAC_DMA_DESC_t myETH_MTL_tx_desc[myETH_MTL_NUM_TX_BUF] __attribute__((section ("ETH_RAM")));
static __attribute__((aligned(4))) uint8_t myETH_MTL_rx_buf[myETH_MTL_NUM_RX_BUF][XMC_ETH_MAC_BUF_SIZE] __attribute__((section ("ETH_RAM")));
static __attribute__((aligned(4))) uint8_t myETH_MTL_tx_buf[myETH_MTL_NUM_TX_BUF][XMC_ETH_MAC_BUF_SIZE] __attribute__((section ("ETH_RAM")));
Note
That specialized memory section must be described in a linker command file which placed in "./bsps/TARGET_APP.../" directory.

Refer to the API reference Ethernet MAC (ETH_MAC) and Ethernet PHY (ETH_PHY) for the API details.
Refer to the device Datasheet and Reference Manual for HW details.

CCU4 Personality

There are two major revisions: 1.0 and 2.0.

CCU4 1.0 is legacy and contains old-style EVENT_HANDLER definitions, which are deprecated and not recommended for usage in new applications.

CCU4 1.0 is left in XMCLib for the backward compatibility with already created projects not to be updated by the user.

The CCU4 1.0 support will be removed in the next major XMCLib revision.

CCU4 2.0 is almost the same as 1.0 but without the deprecated items, so it is recommended for new applications.

Code Generation

Modern INTERRUPT_HANDLER definitions recommended for usage in applications are generated instead of the deprecated items:

ccu4_sr0_setting.png
ccu4_sr0_handler.png

These newly generated definitions can be used in the application code, for example for the xmc4xxx devices:

void MyCCU4_SR0_INTERRUPT_HANDLER(void)
{
}

and for enabling the CCU4 interrupt before starting the block:

NVIC_EnableIRQ(MyCCU4_SR0_IRQN);
XMC_CCU4_SLICE_StartTimer(MyCCU4Slice_HW);

Refer to the API reference Capture Compare Unit 4(CCU4) for the API details.

Refer to the device Datasheet and Reference Manual for the HW details.

DSD Personality

The general DSD block configuration structure:

dsd_settings_general.png

The single channel GUI configurates a separate DSD channel:

dsd_configuration_advanced.png

The Trigger (Integrator) settings are available for Advanced Preconfiguration Mode only.

Code Generation

Note that all the public generated code items are prefixed with the name given in the Device Configurator:

dsd_instName.png

The personality generates a base address, channel ID, and interrupt-related macros that can be used in the application code:

void MyDSD_MAIN_FILTER_INTERRUPT_HANDLER(void)
{
XMC_DSD_ClearResultEventFlag(MyDSD_HW, MyDSD_CH_ID);
}
void MyDSD_AUX_FILTER_INTERRUPT_HANDLER(void)
{
XMC_DSD_ClearAlarmEventFlag(MyDSD_HW, MyDSD_CH_ID);
}

and then, for enabling the DSD interrupts and starting the block itself:

NVIC_EnableIRQ(MyDSD_MAIN_FILTER_IRQN);
NVIC_EnableIRQ(MyDSD_AUX_FILTER_IRQN);
XMC_DSD_Start(MyDSD_HW, MyDSD_CH_ID);

Refer to the API reference Delta Sigma Demodulator (DSD) for the API details.

Refer to the device Datasheet and Reference Manual for the HW details.

HRPWM Personality

Comparator & Slope Generation Unit (CSG)

The personality provides the following functionalities using the CSG peripheral:

  1. Inverting the comparator output.
  2. Blanking the comparator output.
  3. Clamping the comparator output.
  4. Slope generation in Decrementing mode.
  5. Slope generation in Incrementing mode.
  6. Slope generation in Triangle mode.
  7. Updating the slope start and stop value.

High Resolution Channel (HRC)

The personality provides the following functionalities using the CCU8 and HRC peripherals:

  1. PWM signal generation on the selected port pins.
  2. Setting the required frequency of operation and initial duty cycle with the high-resolution positioning.
  3. Start the PWM unit after initialization or at a later time as required.
  4. Operate the PWM in Single shot or Continuous mode.
  5. Start multiple timers in the kernel synchronously.
  6. Generate PWM in Edge/Center aligned, Symmetric/Asymmetric mode.
  7. Select the passive state of the output.
  8. Connect up-to-three external event signals. The following functions can be implemented:
    • External Start
    • External Stop
    • External Count Direction
    • External Gating
    • External Count
    • External Load
    • External Modulation
    • External Override (Level)
    • External Trap
  9. Enable the period match or compare match events.
  10. Generate dead time between complementary outputs.
  11. Generate up-to-two PWMs with CCU8 and HRC slices.

The next figure shows the functional overview of the PWM generation. The period match (PM) value is calculated based on the frequency and the compare match (CM) is calculated based on the duty cycle. The PWM state changes at the period and compare matches.

hrpwm_overview.png
Overview of PWM generation

CCU8 in Edge Aligned Symmetric Mode of Operation

In this mode, we can use the 2 compare registers to generate 2 pairs of complementary outputs, which means a total of 4 outputs. The minimum duty that can be generated is 0% and the maximum is 100%. Here, the output is initially LOW until a compare match occurs. The output remains HIGH until a next match occurs.

hrpwm_edge_symmetric.png
CCU8 in Edge Aligned Symmetric Mode

Example with XMC4400:

\( Clock = 120MHz. \)

\( Prescaler = 0. \)

\( Required\:frequency\:of\:operation\:(F) = 100KHz. \)

\( Duty\:required\:(D) = 30\%. \)

\( Period = \frac{Clock}{(1 \texttt{<<} Prescaler) \cdot F} \)

\( Cmp_{reg} = \frac{Period \cdot (100 - D)}{100} \)

\( Period = \frac{120,000,000}{(1 \texttt{<<} 0) \cdot 100,000} \)

\( Period = 1200 \)   Note: The value loaded to period register is \( (Period - 1) \), i.e. \( 1199. \)

\( Cmp_{reg} = \frac{1200 \cdot (100 - 30)}{100} \)

\( Cmp_{reg} = 840 \)

CCU8 in Center Aligned Symmetric Mode of Operation

In this mode, we can use the 2 compare registers to generate 2 pairs of complementary outputs, which means a total of 4 outputs. The minimum duty that can be generated is 0% and the maximum is 100%. Here, the output is initially LOW. When a compare match occurs during the timer up-counting, the output is set HIGH. The output remains HIGH until a compare match occurs again during the timer down-counting. Here, we can see that the ON time of channel 1 and channel 2 are aligned to the time period center.

hrpwm_center_symmetric.png
CCU8 in Center Aligned Symmetric Mode

Example with XMC4400:

\( Clock = 120MHz. \)

\( Prescaler = 0. \)

\( Required\:frequency\:of\:operation\:(F) = 100KHz. \)

\( Duty\:required\:(D) = 30\%. \)

\( Period = \frac{Clock}{(1 \texttt{<<} Prescaler) \cdot 2F} \)

\( Cmp_{reg} = \frac{Period \cdot (100 - D)}{100} \)

\( Period = \frac{120,000,000}{(1 \texttt{<<} 0) \cdot 2 \cdot 100,000} \)

\( Period = 600 \)   Note: The value loaded to period register is \( (Period - 1) \), i.e. \( 599. \)

\( Cmp_{reg} = \frac{600 \cdot (100 - 30)}{100} \)

\( Cmp_{reg} = 420 \)

CCU8 in Edge Aligned Asymmetric Mode of Operation

In this mode, we can use the 2 compare registers to generate 1 pair of complementary outputs, which means a total of 2 outputs. The minimum duty that can be generated is 0% and the maximum is 100%. Here, the output remains LOW until a channel 1 compare match occurs. This duration can be called "shift". The output remains HIGH until a channel 2 compare match occurs. This duration is determined by the duty. The condition is that the channel 2 register value is required to be greater that the channel 1 register value. This allows us to place the ON time anywhere in the time period, as long as the limiting conditions are met.

hrpwm_edge_asymmetric.png
CCU8 in Edge Aligned Asymmetric Mode

Example with XMC4400:

\( Clock = 120MHz. \)

\( Prescaler = 0. \)

\( Required\:frequency\:of\:operation\:(F) = 100KHz. \)

\( Shift\:required\:(S) = 40\%. \)

\( Duty\:required\:(D) = 30\%. \)

\( Period = \frac{Clock}{(1 \texttt{<<} Prescaler) \cdot F} \)

\( Cmp_{reg1} = \frac{Period \cdot S}{100} \)

\( Cmp_{reg2} = \frac{Period \cdot (S + D)}{100} \)

\( Period = \frac{120,000,000}{(1 \texttt{<<} 0) \cdot 100,000} \)

\( Period = 1200 \)   Note: The value loaded to period register is \( (Period - 1) \), i.e. \( 1199. \)

\( Cmp_{reg1} = \frac{1200 \cdot 40}{100} \)

\( Cmp_{reg1} = 480 \)

\( Cmp_{reg2} = \frac{1200 \cdot (40 + 30)}{100} \)

\( Cmp_{reg2} = 840 \)

CCU8 in Center Aligned Asymmetric Mode of Operation

In this mode, we can use the 2 compare registers to generate 1 pair of complementary outputs, which means a total of 2 outputs. The minimum duty that can be generated is 0% and the maximum is 100%. Here, the output remains LOW until a channel 1 compare match occurs in the timer up-counting. This duration can be called "shift". The output remains HIGH until a channel 2 compare match occurs during the timer down-counting. This duration is determined by the duty.

hrpwm_center_asymmetric.png
CCU8 in Center Aligned Asymmetric Mode

Example with XMC4400:

\( Clock = 120MHz. \)

\( Prescaler = 0. \)

\( Required\:frequency\:of\:operation\:(F) = 100KHz. \)

\( Shift\:required\:(S) = 40\%. \)

\( Duty\:required\:(D) = 40\%. \)

\( Period = \frac{Clock}{(1 \texttt{<<} Prescaler) \cdot 2F} \)

\( Cmp_{reg1} = \frac{2 \cdot Period \cdot S}{100} \)

\( Cmp_{reg2} = \frac{2 \cdot Period \cdot (100 - (S + D))}{100} \)

\( Period = \frac{120,000,000}{(1 \texttt{<<} 0) \cdot 2 \cdot 100,000} \)

\( Period = 600 \)   Note: The value loaded to period register is \( (Period - 1) \), i.e. \( 599. \)

\( Cmp_{reg1} = \frac{2 \cdot 600 \cdot 40}{100} \)

\( Cmp_{reg1} = 480 \)

\( Cmp_{reg2} = \frac{2 \cdot 600 \cdot (40 + 40)}{100} \)

\( Cmp_{reg2} = 480 \)

CCU8 with HRPWM Mode of Operation

hrpwm_ccu8.png
CCU8

Example with XMC4400:

\( Period = 10. \)

\( Duty\:required\:(D) = 60\%. \)

\( Cmp_{reg} = \frac{Period \cdot (100 - D)}{100} \)

\( Cmp_{reg} = \frac{10 \cdot (100 - 60)}{100} \)

\( Cmp_{reg} = 4 \)

Now let us say:

\( Duty\:required\:(D) = 65\%. \)

\( Cmp_{reg} = \frac{10 \cdot (100 - 65)}{100} = 3.5 ≅ 3 \)

With compare register 3, we get a duty of 70%. Therefore, we are not able to get a duty of 65% with a period of 10. Hence, need to use the HRPWM module.

hrpwm_ccu8_hi_res.png
CCU8 with HRPWM

The CCU8 output is fed to the HRPWM module. The HRPWM module has two registers - CR1 and CR2. CR1 delays the rising edge of the output, whereas CR2 extends the falling edge of the output. The High Resolution module has a resolution of 150 Pico second. We can achieve the positioning of the output in the step of 150ps. Thus, by configuring the CR1, CR2 registers we can achieve finer generation of the shift and duty. Refer to the reference manual to determine the minimum and maximum duty cycle feasible with the HRPWM module.

Refer to the API reference High Resolution PWM Unit (HRPWM) for the API details.

Refer to the device Datasheet and Reference Manual for the HW details.

POSIF Personality

Quadrature Decoder Mode

Quadrature Decoder mode is used to find the position and speed of the motor using the incremental encoder. The profile is designed so that it can estimate the angle by consuming 3 CCU4 slices and an optional CCU4 slice along with POSIF and its interconnections.

Four CCU4 slices are consumed for the following purposes:

  1. Position Counter
    • Set the slice to be in Counter mode, which starts ticking based on encoder pulses to provide the absolute position:
    • Connect the Status Signal of the Position Counter CCU4 to an optional Revolution Counter CCU4 slice Event 0 Input Signal.
    • Set the Count Function of the Revolution Counter CCU4 slice to Triggered by Event 0.
    • Set the Event 0 Edge Selection of the Revolution Counter CCU4 slice to Signal Active on Falling Edge.
    • Set the Event 0 Level Selection of the Revolution Counter CCU4 slice to Active on the High Level.
  2. Revolution Counter (optional)
    • Set the slice to be in Counter mode, which ticks based on the Position Counter period match (Falling edge of ST signal).
  3. Time Between Ticks
    • The slice to measure time between ticks for the angle extrapolation.
  4. Time Stamp Trigger
    • The slice to generate a trigger at the time stamp point when the angle extrapolation is required.
    • Connect the Status Signal of the Time Stamp Trigger CCU4 slice to the Position Counter and Revolution Counter CCU4 slices Event 2 Input Signal, and the Time Between Ticks CCU4 slice Event 1 Input Signal.
    • Set the Capture 0 Function of the Position Counter and Revolution Counter CCU4 slices to Triggered by Event 2 and set the Capture 1 Function for the Time Between Ticks CCU4 slice to Triggered by Event 1.
    • Set the Event 2 Edge Selection of the Position Counter and Revolution Counter as well as Event 1 Edge Selection of the Time Between Ticks CCU4 slices to Signal Active on Falling Edge.
    • Set the Event 2 Level Selection of the Position Counter and Revolution Counter as well as Event 1 Level Selection of the Time Between Ticks CCU4 slices to Active on High Level.

The POSIF module and its interconnection with CCU4 are depicted in the following diagram:

posif_encoder_structure.png

Hall Sensor Mode

Hall Sensor mode is used to find the position and speed of the motor using 2 or 3 hall sensors. The POSIF personality in Hall Sensor mode uses two CCU4 slices - one to add a phase delay and one to capture the time between two correct hall patterns.

The personality supports 3 hall sensors and 2 hall sensors in the following use cases:

  1. Find the speed and position for the PMSM motor: In this use case, the speed and position of the PMSM motor is obtained based on the hall sensor input. It is used in the PMSM motor control, which drives the inverter as per SVM algorithm.
  2. Find the speed and position for the BLDC motor: In this use case, the speed and position of the BLDC motor is obtained based on the hall sensor input. It is used in the BLDC motor control, which drives the inverter as per multi-channel pattern sequence.

Refer to the API reference Position Interface Unit (POSIF) for the API details.

Refer to the device Datasheet and Reference Manual for the HW details.

WDT Personality

The Window boundaries configuration:

wdt_window.png
wdt_window_cfg.png

The Pre-Warning Alarm interrupt configuration:

wdt_prewarn.png
wdt_prewarn_cfg.png

Code Generation

The configurator performs the [name]_EventHandler registration in the generated code, so declare it in the application code, for example for the xmc4xxx devices:

void NMI_Handler(void)
{
XMC_SCU_IRQHandler((uint32_t)SCU_0_IRQn);
}
void MyWDT_EventHandler(void)
{
}

and then start the block itself (the rest of configurations are performed in the generated code):

Refer to the API reference Watchdog driver (WDT) for the API details.

Refer to the device Datasheet and Reference Manual for HW details.