FILE: mcpwm_ex7_dma.c
This example demonstrates how to configure MCPWM modules and DMA controllers to implement dynamic updates of PWM parameters without CPU intervention:
MCPWM Configuration:
- MCPWM0 and MCPWM1 are configured for PWM output generation
- MCPWM0 provides SOC trigger for DMA CH1 operations
- MCPWM1 provides SOC trigger for DMA CH2 operations
DMA Configuration:
- DMA CH1 is configured to update MCPWM0 compare registers (PWM1-3 CMPAs) in burst mode, transferring 3 words per trigger
- DMA CH2 is configured to update MCPWM1 compare registers (PWM1 CMPA) in burst mode, transferring 1 word per trigger
- Both DMA channels operate continuously, cycling through 4 different configurations stored in memory
- The example demonstrates advanced PWM pattern generation without CPU overhead by allowing DMA to dynamically update multiple PWM parameters on each PWM period
This technique is particularly useful for:
- Generating complex PWM patterns for motor control
- Creating arbitrary waveforms with precise timing
- Implementing efficient, real-time PWM updates for dynamic system control
External Connections
Monitor the MCPWM pins for the waveforms. Observe J4 40 - GPIO0 - myMCPWM0 Output A1 Observe J4 39 - GPIO1 - myMCPWM0 Output B1 Observe J4 38 - GPIO2 - myMCPWM0 Output A2 Observe J4 37 - GPIO3 - myMCPWM0 Output B2 Observe J4 36 - GPIO4 - myMCPWM0 Output A3 Observe J4 35 - GPIO5 - myMCPWM0 Output B3 Observe J4 7 - GPIO12 - myMCPWM1 Output A1 Observe J2 19 - GPIO29 - myMCPWM1 Output B1
Watch Variables
- compareConfigs_6ch[] - Array containing MCPWM0 compare values for PWM1-3 CMPAs
- compareConfigs_2ch[] - Array containing MCPWM1 compare values for PWM1 CMPA