How infineon/mtb-example-xmc-ccu4-capture works
Project type and purpose
• This is an embedded firmware code example for an Infineon XMC™ MCU.
• It demonstrates CCU4 slice capture and compare functionality: one slice generates a 2 Hz PWM (75 % duty), another slice captures rising/falling edges of that PWM and reports timer values over UART.
• The project uses ModusToolbox™ for project creation, configuration templates for different evaluation kits, XMCLib peripheral drivers, and retarget-io for UART.
Main components
a. Developer Environment (Host PC)
• ModusToolbox™ tools: Eclipse IDE or project-creator-cli
• Makefile orchestrating make getlibs, build, export
• Toolchains: GCC_ARM (default), ARM, or IAR
• Git repo containing source and templates
b. Build System
• Makefile invokes project-creator, fetches libraries in deps/retarget-io-cat3.mtb and XMCLib
• Templates directory (templates/TARGET_…/config/design.modus) provides BSP overrides for each kit
• Compiler/linker assembles main.c and library code into a firmware image
c. Firmware Software Layers
• Application layer: main.c
• Board Support Package (BSP) layer: design.modus files in templates override default pin/peripheral settings
• Peripheral Abstraction: XMCLib CCU4 personalities (PWM_0 and CAPTURE_0), CYBSP_DEBUG_UART personality, retarget-io
d. MCU Hardware
• XMC™ MCU core (e.g., XMC1400, XMC4700, or XMC4800)
• CCU4 Slice 0 configured as PWM generator
• CCU4 Slice 1 configured as capture input
• Single GPIO pin routing PWM output to capture input
• UART peripheral (CYBSP_DEBUG_UART) for debug messages
e. Debug & Communication Interfaces
• SEGGER J-Link: SWD for programming & debugging, CDC UART for serial output
• USB connection to Host PC
f. User Interface (Host PC)
• Terminal emulator (e.g., Tera Term) at 115200 baud, 8N1
Relationships and data flow
1. Development:
Host PC → (project-creator-cli / Eclipse) → generates application skeleton
Makefile → fetch libraries (getlibs) → compile/link → firmware.bin
2. Programming:
Host PC → (J-Link) → flashes firmware.bin into MCU
3. Runtime:
MCU boots → application initializes BSP and peripherals →
• CCU4 PWM_0 toggles output pin at 2 Hz → same pin fed into CCU4 CAPTURE_0 → capture events logged
• On each capture event, firmware reads timer value and calls printf → retarget-io → CYBSP_DEBUG_UART →
MCU UART → (J-Link CDC) → USB → Host PC Terminal emulator displays compare/period values
Architectural patterns & design principles
• Layered modular design: application logic separated from peripheral drivers and BSP
• Template-based configuration: each kit’s design.modus customizes pins and personalities
• Reusable library components: XMCLib modules for CCU4, retarget-io for UART redirection
• Makefile-driven automation for build, library acquisition, and IDE export