/*********************************************************************//** * @brief Initializes the MCPWM peripheral * @param[in] MCPWMx Motor Control PWM peripheral selected, * Should be: LPC_MCPWM * @return None **********************************************************************/ void MCPWM_Init(LPC_MCPWM_TypeDef *MCPWMx) { /* Turn On MCPWM PCLK */ CLKPWR_ConfigPPWR(CLKPWR_PCONP_PCMCPWM, ENABLE); MCPWMx->CAP_CLR = MCPWM_CAPCLR_CAP(0) | MCPWM_CAPCLR_CAP(1) | MCPWM_CAPCLR_CAP(2); MCPWMx->INTF_CLR = MCPWM_INT_ILIM(0) | MCPWM_INT_ILIM(1) | MCPWM_INT_ILIM(2) \ | MCPWM_INT_IMAT(0) | MCPWM_INT_IMAT(1) | MCPWM_INT_IMAT(2) \ | MCPWM_INT_ICAP(0) | MCPWM_INT_ICAP(1) | MCPWM_INT_ICAP(2); MCPWMx->INTEN_CLR = MCPWM_INT_ILIM(0) | MCPWM_INT_ILIM(1) | MCPWM_INT_ILIM(2) \ | MCPWM_INT_IMAT(0) | MCPWM_INT_IMAT(1) | MCPWM_INT_IMAT(2) \ | MCPWM_INT_ICAP(0) | MCPWM_INT_ICAP(1) | MCPWM_INT_ICAP(2); }
/*********************************************************************//** * @brief Initializes the MCPWM peripheral * @param[in] MCPWMx Motor Control PWM peripheral selected, should be: LPC_MCPWM * @return None **********************************************************************/ void MCPWM_Init(LPC_MCPWM_Type *MCPWMx) { /* Turn On MCPWM PCLK */ //LPC_CGU->BASE_VPB1_CLK = (SRC_PL160M_0<<24) | (1<<11); CGU_EntityConnect(CGU_CLKSRC_PLL1, CGU_BASE_APB1); MCPWMx->CAP_CLR = MCPWM_CAPCLR_CAP(0) | MCPWM_CAPCLR_CAP(1) | MCPWM_CAPCLR_CAP(2); MCPWMx->INTF_CLR = MCPWM_INT_ILIM(0) | MCPWM_INT_ILIM(1) | MCPWM_INT_ILIM(2) \ | MCPWM_INT_IMAT(0) | MCPWM_INT_IMAT(1) | MCPWM_INT_IMAT(2) \ | MCPWM_INT_ICAP(0) | MCPWM_INT_ICAP(1) | MCPWM_INT_ICAP(2); MCPWMx->INTEN_CLR = MCPWM_INT_ILIM(0) | MCPWM_INT_ILIM(1) | MCPWM_INT_ILIM(2) \ | MCPWM_INT_IMAT(0) | MCPWM_INT_IMAT(1) | MCPWM_INT_IMAT(2) \ | MCPWM_INT_ICAP(0) | MCPWM_INT_ICAP(1) | MCPWM_INT_ICAP(2); }
/*********************************************************************//** * @brief Initializes the MCPWM peripheral * @param[in] MCPWMx Motor Control PWM peripheral selected, * Should be: LPC_MCPWM * @return None **********************************************************************/ void MCPWM_Init(LPC_MCPWM_TypeDef *MCPWMx) { /* Turn On MCPWM PCLK */ CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCMC, ENABLE); /* As default, peripheral clock for MCPWM module * is set to FCCLK / 2 */ // CLKPWR_SetPCLKDiv(CLKPWR_PCLKSEL_MC, CLKPWR_PCLKSEL_CCLK_DIV_2); MCPWMx->MCCAP_CLR = MCPWM_CAPCLR_CAP(0) | MCPWM_CAPCLR_CAP(1) | MCPWM_CAPCLR_CAP(2); MCPWMx->MCINTFLAG_CLR = MCPWM_INT_ILIM(0) | MCPWM_INT_ILIM(1) | MCPWM_INT_ILIM(2) \ | MCPWM_INT_IMAT(0) | MCPWM_INT_IMAT(1) | MCPWM_INT_IMAT(2) \ | MCPWM_INT_ICAP(0) | MCPWM_INT_ICAP(1) | MCPWM_INT_ICAP(2); MCPWMx->MCINTEN_CLR = MCPWM_INT_ILIM(0) | MCPWM_INT_ILIM(1) | MCPWM_INT_ILIM(2) \ | MCPWM_INT_IMAT(0) | MCPWM_INT_IMAT(1) | MCPWM_INT_IMAT(2) \ | MCPWM_INT_ICAP(0) | MCPWM_INT_ICAP(1) | MCPWM_INT_ICAP(2); }
/*********************************************************************//** * @brief Clears current captured value in specified capture channel * @param[in] MCPWMx Motor Control PWM peripheral selected * Should be: LPC_MCPWM * @param[in] captureChannel Capture channel number, should be: 0..2 * @return None **********************************************************************/ void MCPWM_ClearCapture(LPC_MCPWM_TypeDef *MCPWMx, uint32_t captureChannel) { MCPWMx->MCCAP_CLR = MCPWM_CAPCLR_CAP(captureChannel); }