Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# XMC™ MCU: CCU8 timer synchronous start
This code example demonstrates the synchronous start of capture-compare unit 8 (CCU80 and CCU81) in the XMC™ MCU upon receving a trigger from the event request unit (ERU).
The CCU8 timer slice program blinks the onboard user LEDs (CCU80 blinks user LED1 and CCU81 blinks user LED2) when a timer period match interrupt occurs.
For the XMC1300, XMC4200, and XMC4300 kits which have only one CCU8 timer, Slice 0 and Slice 1 of the timer is used to blink the LED1 and LED2 respectively, when the period match interrupt occurs.
An ERU trigger is used to start the timers synchronously.
## Requirements
- [ModusToolbox™ software](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software/) v3.0
- [SEGGER J-Link software](https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack)
- Programming language: C
- Associated parts: All [XMC™ MCU](https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-arm-cortex-m/) parts
## Supported toolchains (make variable 'TOOLCHAIN')
- GNU Arm® embedded compiler v10.3.1 (`GCC_ARM`) - Default value of `TOOLCHAIN`
## Supported kits (make variable 'TARGET')
- [XMC1300 boot kit](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc13_boot_001/) (`KIT_XMC13_BOOT_001`)
- [XMC1400 boot kit](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc14_boot_001/) (`KIT_XMC14_BOOT_001`) - Default value of `TARGET`
- [XMC4200 Platform2Go kit](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc_plt2go_xmc4200/) (`KIT_XMC_PLT2GO_XMC4200`)
- [XMC4300 relax EtherCAT® kit](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc43_relax_ecat_v1/) (`KIT_XMC43_RELAX_ECAT_V1`)
- [XMC4400 Platform2Go kit](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc4400_dc_v1/) (`KIT_XMC_PLT2GO_XMC4400`)
- [XMC4500 relax kit](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc45_relax_v1/) (`KIT_XMC45_RELAX_V1`)
- [XMC4700 relax kit](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc47_relax_v1/) (`KIT_XMC47_RELAX_V1`)
- [XMC4800 relax EtherCAT® kit](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc48_relax_ecat_v1/) (`KIT_XMC48_RELAX_ECAT_V1`)
## Hardware setup
For the ERU trigger to start the timers, a falling edge is required, which is configured as below:
1. On the XMC1300 and the XMC1400 boot kits, the potentiometer connected to pin 2_5 is enabled and is used to introduce the negative edge trigger.
For the kits mentioned below, a negative falling edge can be introduced by having an external pull-up circuit powered by a 5-V source.
2. For the XMC4200 Platform2Go kit, pin 1_15 is used to introduce a negative edge trigger. Since this kit has only one user LED, pin 1_7 is used to check the second output.
3. For the XMC4300 relax EtherCAT® kit, pin 2_3 is used to introduce a negative edge trigger.
4. For the XMC4400, XMC4500, XMC4700, and XMC4800 kits, pin 1_15 is used to introduce a negative edge trigger.
## Software setup
This example requires no additional software or tools.
## Using the code example
Create the project and open it using one of the following:
<details open><summary><b>In Eclipse IDE for ModusToolbox&trade; software</b></summary>
1. Click the **New Application** link in the **Quick Panel** (or, use **File** > **New** > **ModusToolbox Application**). This launches the [Project Creator](https://www.infineon.com/dgdl/Infineon-ModusToolbox_Project_Creator_Guide_3-UserManual-v01_00-EN.pdf?fileId=8ac78c8c7d718a49017d99bcabbd31e5) tool.
2. Pick a kit supported by the code example from the list shown in the **Project Creator - Choose Board Support Package (BSP)** dialog.
When you select a supported kit, the example is reconfigured automatically to work with the kit. To work with a different supported kit later, use the [Library Manager](https://www.infineon.com/dgdl/Infineon-ModusToolbox_Library_Manager_User_Guide_3-UserManual-v01_00-EN.pdf?fileId=8ac78c8c7d718a49017d99ab34b831ce) to choose the BSP for the supported kit. You can use the Library Manager to select or update the BSP and firmware libraries used in this application. To access the Library Manager, click the link from the **Quick Panel**.
You can also just start the application creation process again and select a different kit.
If you want to use the application for a kit not listed here, you may need to update the source files. If the kit does not have the required resources, the application may not work.
3. In the **Project Creator - Select Application** dialog, choose the example by enabling the checkbox.
4. (Optional) Change the suggested **New Application Name**.
5. The **Application(s) Root Path** defaults to the Eclipse workspace which is usually the desired location for the application. If you want to store the application in a different location, you can change the *Application(s) Root Path* value. Applications that share libraries should be in the same root path.
6. Click **Create** to complete the application creation process.
For more details, see the [Eclipse IDE for ModusToolbox&trade; software user guide](https://www.infineon.com/dgdl/Infineon-Eclipse_IDE_for_ModusToolbox_User_Guide_1-UserManual-v01_00-EN.pdf?fileId=8ac78c8c7d718a49017d99bcb86331e8) (locally available at *{ModusToolbox&trade; software install directory}/ide_{version}/docs/mt_ide_user_guide.pdf*).
</details>
<details open><summary><b>In command-line interface (CLI)</b></summary>
ModusToolbox&trade; software provides the Project Creator as both a GUI tool and the command line tool, "project-creator-cli". The CLI tool can be used to create applications from a CLI terminal or from within batch files or shell scripts. This tool is available in the *{ModusToolbox&trade; software install directory}/tools_{version}/project-creator/* directory.
Use a CLI terminal to invoke the "project-creator-cli" tool. On Windows, use the command line "modus-shell" program provided in the ModusToolbox&trade; software installation instead of a standard Windows command-line application. This shell provides access to all ModusToolbox&trade; software tools. You can access it by typing `modus-shell` in the search box in the Windows menu. In Linux and macOS, you can use any terminal application.
This tool has the following arguments:
Argument | Description | Required/optional
---------|-------------|-----------
`--board-id` | Defined in the `<id>` field of the [BSP](https://github.com/Infineon?q=bsp-manifest&type=&language=&sort=) manifest | Required
`--app-id` | Defined in the `<id>` field of the [CE](https://github.com/Infineon?q=ce-manifest&type=&language=&sort=) manifest | Required
`--target-dir`| Specify the directory in which the application is to be created if you prefer not to use the default current working directory | Optional
`--user-app-name`| Specify the name of the application if you prefer to have a name other than the example's default name | Optional
<br>
The following example will clone the "[CCU8 Sync Start](https://github.com/Infineon/mtb-example-xmc-ccu8-sync-start)" application with the desired name "CCU8-Sync-Start" configured for the *KIT_XMC14_BOOT_001* BSP into the specified working directory, *C:/mtb_projects*:
```
project-creator-cli --board-id KIT_XMC14_BOOT_001 --app-id mtb-example-xmc-tse-calc-temperature --user-app-name TSE calc temperature --target-dir "C:/mtb_projects"
```
**Note:** The project-creator-cli tool uses the `git clone` and `make getlibs` commands to fetch the repository and import the required libraries. For details, see the "Project creator tools" section of the [ModusToolbox&trade; software user guide](https://www.infineon.com/dgdl/Infineon-ModusToolbox_2.4_User_Guide-Software-v01_00-EN.pdf?fileId=8ac78c8c7e7124d1017ed97e72563632) (locally available at *{ModusToolbox&trade; software install directory}/docs_{version}/mtb_user_guide.pdf*).
</details>
<details open><summary><b>In third-party IDEs</b></summary>
**Note:** Only VS code is supported.
1. Follow the instructions from the **In command-line interface (CLI)** section to create the application, and import the libraries using the `make getlibs` command.
2. Export the application to a supported IDE using the `make <ide>` command.
For a list of supported IDEs and more details, see the "Exporting to IDEs" section of the [ModusToolbox&trade; software user guide](https://www.infineon.com/dgdl/Infineon-ModusToolbox_2.4_User_Guide-Software-v01_00-EN.pdf?fileId=8ac78c8c7e7124d1017ed97e72563632) (locally available at *{ModusToolbox&trade; software install directory}/docs_{version}/mtb_user_guide.pdf*).
3. Follow the instructions displayed in the terminal to create or import the application as an IDE project.
</details>
## Operation
1. Connect the board to your PC using a micro-USB cable through the debug USB connector.
2. Program the board using Eclipse IDE for ModusToolbox&trade; software:
1. Select the application project in Project Explorer.
2. In the **Quick Panel**, scroll down, and click **\<Application Name> Program (JLink)**.
3. To introduce the negative edge for the ERU trigger, follow the below steps for different kits:
1. If using the XMC1300 and XMC1400 boot kit, rotate the potentiometer to introduce the ERU trigger.
2. If using the XMC4500 kit, press **BUTTON2**.
3. For the remaining kits, introduce a negative edge trigger on pin 1_15.
4. Once the triggers are introduced, user LEDs on the kit start blinking alternatively at approximately 2 seconds.
5. The following waveforms indicate the synchronous start of the CCU8 timers.
- LED1 is LOW and LED2 is HIGH as indicated by the yellow and purple waveforms respectively in Figure 1.
**Figure 1. Initial state of LEDS**
![](images/capture12.png)
<br>
- LED1 and LED2 start blinking simultaneously as indicated by the yellow and purple waveforms in Figure 2.
**Figure 2. Blinking of LEDS**
![](images/capture1.png)
## Debugging
You can debug the example to step through the code. In the IDE, use the **\<Application Name> Debug (JLink)** configuration in the **Quick Panel**. For more details, see the "Program and Debug" section in the [Eclipse IDE for ModusToolbox&trade; software user guide](https://www.infineon.com/dgdl/Infineon-Eclipse_IDE_for_ModusToolbox_User_Guide_1-UserManual-v01_00-EN.pdf?fileId=8ac78c8c7d718a49017d99bcb86331e8).
## Design and implementation
This code example demonstrates the use of two capture-compare unit 8 (CCU8) timers (CCU80 and CCU81) (for XMC1400, 4400, 4500, 4700, and 4800 kits) operating on their first slices. For the XMC1300, 4200, and 4300 kits which have only one CCU8 timer, the zero and first slice of the timer is used in starting the two timers synchronously when an event is registered by the ERU. A falling edge is used to register the event on the ERU.
On the XMC1300 and XMC1400 kits, the onboard potentiometer (internally connected to the P2_5 pin) is used to register the event.
On the XMC4300, 4400, 4700 and 4800 kits, pin 1_15 is set as an input and pull up mode is selected to register the ERU event triggered by the negative edge.
On the XMC4200 kit, along with configuring pin 1_15 as mentioned above, pin 1_7 is configured as an output to record the second output since this board does not have a second user LED.
To set the above configurations, the pins must be enabled in the *design.modus* file in the folder *\COMPONENT_CUSTOM_DESIGN_MODUS\TARGET_KIT_* *.
An example for the *TARGET_KIT_XMC14_BOOT_001* is shown in Figure 3. The *design.modus* is available at: *\COMPONENT_CUSTOM_DESIGN_MODUS\TARGET_KIT_XMC14_BOOT_001*.
The method of configuring the *design.modus* remains the same throughout all the boards.
**Figure 3. - Personality setup**
![](images/xmc1400designmodus.png)
## Related resources
Resources | Links
-----------|----------------------------------
Code examples | [Using ModusToolbox&trade; software](https://github.com/Infineon/Code-Examples-for-ModusToolbox-Software) on GitHub
Device documentation | [XMC1000 family datasheets](https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-arm-cortex-m/32-bit-xmc1000-industrial-microcontroller-arm-cortex-m0/#document-group-myInfineon-49) <br> [XMC1000 family technical reference manuals](https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-arm-cortex-m/32-bit-xmc1000-industrial-microcontroller-arm-cortex-m0/#document-group-myInfineon-44) <br> [XMC4000 family datasheets](https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-arm-cortex-m/32-bit-xmc4000-industrial-microcontroller-arm-cortex-m4/#document-group-myInfineon-49) <br> [XMC4000 family technical reference manual](https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-arm-cortex-m/32-bit-xmc4000-industrial-microcontroller-arm-cortex-m4/#document-group-myInfineon-44)
Development kits | [XMC&trade; eval boards](https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-arm-cortex-m/#boards)
Libraries on GitHub | [mtb-xmclib-cat3](https://github.com/Infineon/mtb-xmclib-cat3) – XMC&trade; peripheral library (XMCLib)
Tools | [Eclipse IDE for ModusToolbox&trade; software](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software) – ModusToolbox&trade; software is a collection of easy-to-use software and tools enabling rapid development with Infineon MCUs, covering applications from embedded sense and control to wireless and cloud-connected systems using AIROC&trade; Wi-Fi and Bluetooth® connectivity devices.
## Other resources
Infineon provides a wealth of data at www.infineon.com to help you select the right device, and quickly and effectively integrate it into your design.
For XMC&trade; MCU devices, see [32-bit XMC™ industrial microcontroller based on Arm® Cortex®-M](https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-arm-cortex-m/).
## Document history
Document title: *CE232666* - *XMC&trade; MCU: CCU8 timer synchronous start*
| Version | Description of change |
| ------- | --------------------- |
| 1.0.0 | New code example |
| 1.1.0 | Added support for new kits |
| 2.0.0 | Added support for CCU8 personality; Updated to support ModusToolbox&trade; software v3.0; CE will not be backwards compatible with previous versions of ModusToolbox™ software |
| 2.0.1 | Updated README |
------
All other trademarks or registered trademarks referenced herein are the property of their respective owners.
© 2022 Infineon Technologies AG
All Rights Reserved.
### Legal disclaimer
The information given in this document shall in no event be regarded as a guarantee of conditions or characteristics. With respect to any examples or hints given herein, any typical values stated herein and/or any information regarding the application of the device, Infineon Technologies hereby disclaims any and all warranties and liabilities of any kind, including without limitation, warranties of non-infringement of intellectual property rights of any third party.
### Information
For further information on technology, delivery terms and conditions and prices, please contact the nearest Infineon Technologies Office (www.infineon.com).
### Warnings
Due to technical requirements, components may contain dangerous substances. For information on the types in question, please contact the nearest Infineon Technologies Office.
Infineon Technologies components may be used in life-support devices or systems only with the express written approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure of that life-support device or system or to affect the safety or effectiveness of that device or system. Life support devices or systems are intended to be implanted in the human body or to support and/or maintain and sustain and/or protect human life. If they fail, it is reasonable to assume that the health of the user or other persons may be endangered.
-------------------------------------------------------------------------------