mirror of https://github.com/ARMmbed/mbed-os.git
M263: modify epwm-config-output
parent
2596b7c7be
commit
a62c877d0e
|
@ -103,6 +103,26 @@ uint32_t EPWM_ConfigCaptureChannel(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_
|
|||
* To change duty cycle later, it should get the configured period value and calculate the new comparator value.
|
||||
*/
|
||||
uint32_t EPWM_ConfigOutputChannel(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle)
|
||||
{
|
||||
return EPWM_ConfigOutputChannel2(epwm, u32ChannelNum, u32Frequency, u32DutyCycle, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function Configure EPWM generator and get the nearest frequency in edge aligned(up counter type) auto-reload mode
|
||||
* @param[in] epwm The pointer of the specified EPWM module
|
||||
* - EPWM0 : EPWM Group 0
|
||||
* - EPWM1 : EPWM Group 1
|
||||
* @param[in] u32ChannelNum EPWM channel number. Valid values are between 0~5
|
||||
* @param[in] u32Frequency Target generator frequency
|
||||
* @param[in] u32DutyCycle Target generator duty cycle percentage. Valid range are between 0 ~ 100. 10 means 10%, 20 means 20%...
|
||||
* @param[in] u32Frequency2 Target generator frequency = u32Frequency / u32Frequency2
|
||||
* @return Nearest frequency clock in nano second
|
||||
* @note Since every two channels, (0 & 1), (2 & 3), shares a prescaler. Call this API to configure EPWM frequency may affect
|
||||
* existing frequency of other channel.
|
||||
* @note This function is used for initial stage.
|
||||
* To change duty cycle later, it should get the configured period value and calculate the new comparator value.
|
||||
*/
|
||||
uint32_t EPWM_ConfigOutputChannel2(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle, uint32_t u32Frequency2)
|
||||
{
|
||||
uint32_t u32PWMClockSrc;
|
||||
uint32_t i;
|
||||
|
@ -113,14 +133,15 @@ uint32_t EPWM_ConfigOutputChannel(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t
|
|||
{
|
||||
u32PWMClockSrc = CLK_GetPCLK0Freq();
|
||||
}
|
||||
else /* if((epwm == EPWM1)||(epwm == EPWM1_NS)) */
|
||||
else /* if(epwm == EPWM1) */
|
||||
{
|
||||
u32PWMClockSrc = CLK_GetPCLK1Freq();
|
||||
}
|
||||
|
||||
for(u32Prescale = 1U; u32Prescale < 0xFFFU; u32Prescale++)/* prescale could be 0~0xFFF */
|
||||
{
|
||||
i = (u32PWMClockSrc / u32Frequency) / u32Prescale;
|
||||
// Note: Support frequency < 1
|
||||
i = (uint64_t) u32PWMClockSrc * u32Frequency2 / u32Frequency / u32Prescale;
|
||||
/* If target value is larger than CNR, need to use a larger prescaler */
|
||||
if(i <= (0x10000U))
|
||||
{
|
||||
|
|
|
@ -541,6 +541,11 @@ extern "C"
|
|||
/*---------------------------------------------------------------------------------------------------------*/
|
||||
uint32_t EPWM_ConfigCaptureChannel(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32UnitTimeNsec, uint32_t u32CaptureEdge);
|
||||
uint32_t EPWM_ConfigOutputChannel(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle);
|
||||
uint32_t EPWM_ConfigOutputChannel2(EPWM_T *epwm,
|
||||
uint32_t u32ChannelNum,
|
||||
uint32_t u32Frequency,
|
||||
uint32_t u32DutyCycle,
|
||||
uint32_t u32Frequency2);
|
||||
void EPWM_Start(EPWM_T *epwm, uint32_t u32ChannelMask);
|
||||
void EPWM_Stop(EPWM_T *epwm, uint32_t u32ChannelMask);
|
||||
void EPWM_ForceStop(EPWM_T *epwm, uint32_t u32ChannelMask);
|
||||
|
|
Loading…
Reference in New Issue