TM STM32F4xx Libraries  v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
TM_PWM_Functions

Library Functions. More...

Functions

TM_PWM_Result_t TM_PWM_InitTimer (TIM_TypeDef *TIMx, TM_PWM_TIM_t *TIM_Data, double PWMFrequency)
 Initializes specific timer for PWM capability. More...
 
TM_PWM_Result_t TM_PWM_InitChannel (TM_PWM_TIM_t *TIM_Data, TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack)
 Initializes channel used for specific timer. More...
 
TM_PWM_Result_t TM_PWM_SetChannel (TM_PWM_TIM_t *TIM_Data, TM_PWM_Channel_t Channel, uint32_t Pulse)
 Sets PWM value for specific timer and channel. More...
 
TM_PWM_Result_t TM_PWM_SetChannelPercent (TM_PWM_TIM_t *TIM_Data, TM_PWM_Channel_t Channel, float percent)
 Sets PWM value for specific timer and channel with percentage feature. More...
 
TM_PWM_Result_t TM_PWM_SetChannelMicros (TM_PWM_TIM_t *TIM_Data, TM_PWM_Channel_t Channel, uint32_t micros)
 Sets PWM value for specific timer and channel with pulse high time feature. More...
 

Detailed Description

Library Functions.

Function Documentation

TM_PWM_Result_t TM_PWM_InitChannel ( TM_PWM_TIM_t TIM_Data,
TM_PWM_Channel_t  Channel,
TM_PWM_PinsPack_t  PinsPack 
)

Initializes channel used for specific timer.

Parameters
*TIM_DataPointer to struct with already initialized timer for PWM
ChannelSelect channel you will use on specific timer. This parameter can be a value of TM_PWM_Channel_t
PinsPackSelect which pinspack you will use for pin. This parameter can be a value of TM_PWM_PinsPack_t
Return values
Memberof TM_PWM_Result_t
TM_PWM_Result_t TM_PWM_InitTimer ( TIM_TypeDef *  TIMx,
TM_PWM_TIM_t TIM_Data,
double  PWMFrequency 
)

Initializes specific timer for PWM capability.

Parameters
*TIMxPointer to selected timer, you want to use for PWM
*TIM_DataPointer to blank TM_PWM_TIM_t structure. Here will init function save all data for specific timer
PWMFrequencySelect custom frequency for PWM
Return values
Memberof TM_PWM_Result_t
TM_PWM_Result_t TM_PWM_SetChannel ( TM_PWM_TIM_t TIM_Data,
TM_PWM_Channel_t  Channel,
uint32_t  Pulse 
)

Sets PWM value for specific timer and channel.

Parameters
*TIM_DataPointer to struct with already initialized timer for PWM
ChannelSelect channel you will use on specific timer. This parameter can be a value of TM_PWM_Channel_t
PulsePulse, to be set for compare match
Return values
Memberof TM_PWM_Result_t
TM_PWM_Result_t TM_PWM_SetChannelMicros ( TM_PWM_TIM_t TIM_Data,
TM_PWM_Channel_t  Channel,
uint32_t  micros 
)

Sets PWM value for specific timer and channel with pulse high time feature.

Note
You have to specify amount of micro seconds pulse will be high for specific timer and channel. This method is not so good on PWM large than 100k, because you cannot set nice and correct settings, with microseconds accuracy. It is perfect, and was designed for low frequencies, eg. use with servos, where you have exact amount of time for servo's rotation.
Parameters
*TIM_DataPointer to struct with already initialized timer for PWM
ChannelSelect channel you will use on specific timer. This parameter can be a value of TM_PWM_Channel_t
microsMicroseconds for pulse high on PWM. Cannot be large than timer period in micros. PWM 1kHz = Timer period = 1000000 / 1000 = 1000us. This parameter can not be greater than 1000us in this case.
Return values
Memberof TM_PWM_Result_t
TM_PWM_Result_t TM_PWM_SetChannelPercent ( TM_PWM_TIM_t TIM_Data,
TM_PWM_Channel_t  Channel,
float  percent 
)

Sets PWM value for specific timer and channel with percentage feature.

Parameters
*TIM_DataPointer to struct with already initialized timer for PWM
ChannelSelect channel you will use on specific timer. This parameter can be a value of TM_PWM_Channel_t
percentPercentage from 0 to 100, to set PWM duty cycle
Return values
Memberof TM_PWM_Result_t