【Infineon XMC 應用筆記】 XMC1000 and XMC4000 CCU8 捕獲比較單元 Part 2

1. CCU8 PWM多通道控制:

每個CAPCOM8(CCU80/-81)單元都是一個可用於多種應用的多用途計時單元。它由基本功能完全相同的計時子模組單元組成的結。這允許重複使用開發的軟體底層驅動程式。圖為CC8x單元4個CC8y計時子模組之一的功能方塊圖。
多通道功能可運用於馬達電機三相控制,和電源全橋控制應用中。


2. CCU8 PWM死區時間生成:

每個CAPCOM8 計時子模組都提供兩個獨立的8 位死區時間計數器,這兩個計數器可以在兩個比較通道的上升和下降的轉變中生成獨立的死區時間。這個可以用於防止短路,例如可以用於對由MOSFETH組成的H橋的優化控制。



3. CCU8 Configuration and LLD Example Code:

#include "xmc_ccu8.h"

//* CCU8 Configuration for the 3 Slices */
static const XMC_CCU8_SLICE_COMPARE_CONFIG_t SLICE_config =
{
          .timer_mode = (uint32_t)XMC_CCU8_SLICE_TIMER_COUNT_MODE_CA,
          .monoshot = (uint32_t)XMC_CCU8_SLICE_TIMER_REPEAT_MODE_REPEAT,
          .shadow_xfer_clear = 0U,
          .dither_timer_period = 0U,
          .dither_duty_cycle = 0U,
          .prescaler_mode = (uint32_t)XMC_CCU8_SLICE_PRESCALER_MODE_NORMAL,
          .mcm_ch1_enable = 0U,
          .mcm_ch2_enable = 0U,
          .slice_status = (uint32_t)XMC_CCU8_SLICE_STATUS_CHANNEL_1,
          .passive_level_out0 = (uint32_t)XMC_CCU8_SLICE_OUTPUT_PASSIVE_LEVEL_LOW,
          .passive_level_out1 = (uint32_t)XMC_CCU8_SLICE_OUTPUT_PASSIVE_LEVEL_LOW,
          .passive_level_out2 = (uint32_t)XMC_CCU8_SLICE_OUTPUT_PASSIVE_LEVEL_LOW,
          .passive_level_out3 = (uint32_t)XMC_CCU8_SLICE_OUTPUT_PASSIVE_LEVEL_LOW,
          .asymmetric_pwm = 0U,
          .invert_out0 = 0U,
          .invert_out1 = 1U,
          .invert_out2 = 0U,
          .invert_out3 = 1U,
          .prescaler_initval = 0U,
          .float_limit = 0U,
          .dither_limit = 0U,
          .timer_concatenation = 0U,
};

/* Dead time configuration structure*/
XMC_CCU8_SLICE_DEAD_TIME_CONFIG_t SLICE_dt_config =
{
          .enable_dead_time_channel1 = 1U,
          .enable_dead_time_channel2 = 0U,
          .channel1_st_path = 1U,
          .channel1_inv_st_path = 1U,
          .channel2_st_path = 0U,
          .channel2_inv_st_path = 0U,
          .div = (uint32_t) XMC_CCU8_SLICE_DTC_DIV_1,

          .channel1_st_rising_edge_counter = 24U,
          .channel1_st_falling_edge_counter = 12U,
          .channel2_st_rising_edge_counter = 0U,
          .channel2_st_falling_edge_counter = 0U,
};

//Enable clock
XMC_CCU8_Init(CCU80, XMC_CCU8_SLICE_MCMS_ACTION_TRANSFER_PR_CR);
//Start the prescaler
XMC_CCU8_StartPrescaler(CCU80);
//Start of CCU8 configurations
XMC_CCU8_SetModuleClock(CCU80, XMC_CCU8_CLOCK_SCU);
//Configure CCU8x_CC8y slice as timer
XMC_CCU8_SLICE_CompareInit(SLICE0_PTR, &SLICE_config);
//Set period match value
XMC_CCU8_SLICE_SetTimerPeriodMatch(SLICE0_PTR, Period_Value);
//Set timer compare match value for duty
XMC_CCU8_SLICE_SetTimerCompareMatch(SLICE0_PTR, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, (Period_Value >> 1));
XMC_CCU8_SLICE_SetTimerCompareMatch(SLICE0_PTR, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, (Period_Value >> 1));
//Transfer value from shadow
XMC_CCU8_EnableShadowTransfer(MODULE_PTR, XMC_CCU8_SHADOW_TRANSFER_SLICE_0);
//Configure events
XMC_CCU8_SLICE_ConfigureEvent(SLICE0_PTR, XMC_CCU8_SLICE_EVENT_0, &SLICE_event0_config);
XMC_CCU8_SLICE_StartConfig(SLICE0_PTR, XMC_CCU8_SLICE_EVENT_0, XMC_CCU8_SLICE_START_MODE_TIMER_START_CLEAR);
//Enable events
XMC_CCU8_SLICE_EnableEvent(SLICE0_PTR, XMC_CCU8_SLICE_IRQ_ID_PERIOD_MATCH);
XMC_CCU8_SLICE_EnableEvent(SLICE0_PTR, XMC_CCU8_SLICE_IRQ_ID_ONE_MATCH);
//Connect SR0
XMC_CCU8_SLICE_SetInterruptNode(SLICE0_PTR, XMC_CCU8_SLICE_IRQ_ID_PERIOD_MATCH, XMC_CCU8_SLICE_SR_ID_0);
//Set NVIC priority
NVIC_SetPriority(CCU80_0_IRQn, 63U);
//Enable IRQ
NVIC_EnableIRQ(CCU80_0_IRQn);
//Deadtime initialisation
XMC_CCU8_SLICE_DeadTimeInit(SLICE0_PTR, &SLICE_dt_config);
XMC_CCU8_EnableClock(MODULE_PTR, SLICE0_NUMBER);



4. 參考資料來源:
(1) Peripheral - Capture and Compare Unit 8 (CCU8)
https://www.infineon.com/dgdl/Infineon-IP_CCU8_XMC-TR-v01_02-EN.pdf?fileId=5546d4624ad04ef9014b0780b3482262
(2) AP32288 - XMC1000/XMC4000 - Capture Compare Unit 8(CCU8)
https://www.infineon.com/dgdl/Infineon-CCU8-XMC1000_XMC4000-AP32288-AN-v01_01-EN.pdf?fileId=5546d4624e765da5014ed8dd5c7d1730
(3) XMC4700 XMC4800 Reference Manual
https://www.infineon.com/dgdl/Infineon-ReferenceManual_XMC4700_XMC4800-UM-v01_03-EN.pdf?fileId=5546d462518ffd850151904eb90c0044

★博文內容均由個人提供,與平台無關,如有違法或侵權,請與網站管理員聯繫。

★博文作者未開放評論功能