Generation of PWM signals
Pulse Width Modulation, or PWM is a technique to generate analog signals on the output pins. High resolution counters are used to generate square wave with variable duty cycle. Generation of analog signal on microcontroller can be done by using three ways:
1. By using internal PWM module present in microcontroller.
2. By using timers/ Counters present in microcontroller.
3. Directly by using software model.
In this tutorial I have shown how to generate PWM signals by using internal PWM module present in Microcontroller.
TM4C123GH6PM microcontroller consists of total two PWM modules, with four PWM generator in each modules. Each PWM generator generates two PWM signals. GPIO pins support Multi-functional operations. They are configure as PWM output for PWM signals. On headers total 16 PWM signals are available. This signals can be control by using Period of signal and Duty cycle.
Period: Period is an addition of total ON time and OFF time signal in one cycle.
Duty cycle: Duty cycle indicates percentage of ON time in a single cycle.
% Duty Cycle = [(Ton Time) / (Ton Time + Toff Time)] * 100
Configure GPIO pins aa a PWM signal:
1. Set clock frequency for PWM modules. By using SYS_DIV function PWM clock is generated using system clock frequency.
2. Enable PWM module 0 or PWM module 1.
3. Configure GPIO pin for alternate function as PWM signal using GPIO_x*_My*PWMz*
Notation: x* denotes GPIO pin number, y* denotes PWM module number, z* denotes PWM signal number in respective module.
4. Configure PWM generator for UP count, DOWN count, UP-DOWN count, synchronization, debug or fault handler operation.
5. Set total time period for particular PWM generator in terms of clock ticks.
6. Enable particular PWM output signal.
7. Enable particular PWM generator.
8. Now set width of pulse according to analog value.
Comments
Post a Comment