3.3.3 Setup
These are the settings for the TCE and WEX peripherals made with MCC:
- Module Enable: Must be enabled by default. If not, toggle the button (it turns blue if enabled)
- Clock Selection: System clock (by default, the divider must be 1 - System clock)
- Counter Direction: UP
- Waveform Generation Mode: Single-Slope PWM mode with overflow on TOP
- Requested Period [s]: 0.00005
- Duty Cycle 0 [%]: 0
- Duty Cycle 1 [%]: 0
- Duty Cycle 2 [%]: 0
- Duty Cycle 3 [%]: 0
- Waveform Output n: Check the boxes from the Enable column for Waveform Output 0, 1, 2, 3
- Scale mode: CMP values are scaled from the Bottom, 50% DC (duty cycle)
- Scaled Writing to registers: Normal
- Amplitude Control Enable: Toggle the button (it turns blue if enabled)
- Generate ISR: Toggle the button (it turns blue if enabled)
- Overflow Interrupt Enable: Toggle the button (it turns blue if enabled)
WEX configurations:
- Input Matrix: Direct
- Update Source: TCE (the update condition for the output signals will be dictated by TCE)
- Override Settings: Check all the boxes from the Output Enable column for the Waveform Output [0-7]
- Dead-time Insertion Channel 0 Enable: Toggle the button (it turns blue if enabled)
- Dead-time Insertion Channel 1 Enable: Toggle the button (it turns blue if enabled)
- Dead-time Insertion Channel 2 Enable: Toggle the button (it turns blue if enabled)
- Dead-time Insertion Channel 3 Enable: Toggle the button (it turns blue if enabled)
- Requested Dead-time Low Side (μs): 0.2
- Requested Dead-time High Side (μs): 0.2
After the MCC libraries are generated, the code is only sufficient for peripheral
initialization, to spin the motor the demo files must be added. The
"stepper.c
" and "stepper.h
" files must be added
and the "main.c
" file must be edited to call the dedicated APIs.