PWM Init

From OpenMBD
< HANcoder‎ | STM32‎ | Blocks
Jump to: navigation, search
Supported Targets: Olimexino, E407, P405

General information about PWM Init

A 'PWM Init' block configures one of the STM32 timer modules for PWM functionality, allowing a PWM signal to be generated on up to 4 timer channels and their associated output pins. Additionally, a function-call subsystem can be connected to the IRQ output. The subsystem will execute each time a PWM period completes.

The generation of the PWM signal can be enabled and disabled per channel.

The frequency of the PWM signal is configured on a module level. So the same configured frequency is used on all enabled channels.

The timer module 1 on the STM32 (TIM1) has a special feature on the first 3 channels. It can output 2 signals on 2 micro controller pins where the second signal is the inverted of the first signal.

Block

PWMInit.png

Mask

PWMInitMask.png

Block inputs (inports)

Input: The value of the duty cycle in 100/1023[%].(512=50%, 1023=100%).(uint16)

Block outputs (outports)

Fcn callback output (optional): When the enable IRQ output option is checked, an extra output will appear, this output can be attached to a Function-Call subsystem. This subsystem will be executed on the edge of the signal. (exact execution depends on the signal alignment)

Block parameters

Parameter Description
PWM Module Select the output pin where the PWM signal should be generated.
Signal frequency The frequency of the PWM signal. Not all frequencies can be achieved with the multipliers in the mirco controller so the block will calculate the frequency closest to the desired frequency. It will show this frequency after Apply is pressed.
Signal alignment Determines the alignment of the signal. It can either be edge aligned or center aligned.
Enable IQR Output When this box is ticked an extra output will become available where an interrupt Function-Call subsystem can be connected.
Generate PWM signal on channel x (Channel x tab) When this box is ticked a PWM signal can be made on this channel. Note that the pins written in the 'PWM module' parameter are in order of channel, so the first one is channel 1 and the second channel 2.
Select signal polarity When Active high a duty cycle of 75% will generate an electric signal 3/4 of the time high, when active low the same duty cycle will generate an electric signal which is 1/4 of the time high.
Enable inverted signal on additional output pin With some channels and pins it is possible to generate the inverse of the signal on an additional output pin.

See Also

PWM Duty Cycle