1 / 12

Pulse Width Modulator (PWM)

Pulse Width Modulator (PWM). PWMConfigure.c Establish PWMConfigure.c files, and join it into the project. PWMConfigure.c file is responsible for the initialization of PWM.It enables the PWM generator and output pins, and set the PWM output cycle and duty cycle.

kalea
Download Presentation

Pulse Width Modulator (PWM)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pulse Width Modulator (PWM)

  2. PWMConfigure.c • Establish PWMConfigure.c files, and join it into the project. • PWMConfigure.c file is responsible for the initialization of PWM.It enables the PWM generator and output pins, and set the PWM output cycle and duty cycle. • First of all, we add the following references in PWMConfigure.c file: • #include "HardwareLibrary.h" • #include "LuminaryDriverLibrary.h" • #include "SysCtlConfigure.h" • #include "PWMConfigure.h" • These reference file let us call the chip to enable and set functions. The PWMConfigure.h set up this section in the experiment using the cycle of PWM output. • We define t PWM initialization function PWMInitial(). • voidPWMInitial(void) • { • } • Then in PWMInital(), we call the function SysCtlPeripheralEnable (), SysCtlPWMClockSet (), PWMGenConfigure (), PWMGenPeriodSet (), PWMPulseWidthSet (), PWMOutputState (), PWMGenEnable () to initialize the PWM modulein turn. • Function SysCtlPeripheralEnable (SYSCTL_PERIPH_PWM) can enable the PWM module,SysCtlPWMClockSet (SYSCTL_PWMDIV_1) set the clock frequency to be 1. The function PWMGenConfigure () initializes the PWM signal generator.Because we export pin 5 of PWM module to LED0, we choose corresponding PWM_GEN_2 signal generator andenable the output pin 5.We use PWMGenConfigure (PWM_BASE PWM_GEN_2, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC) to initialize PWM_GEN_2. Function PWMGenPeriodSet() andPWMPulseWidthSet() set the PWM output cycle and duty cycle. Then we use the function PWMOutputState () toenable the output of the PWM module pin 5, PWMOutputState (PWM_BASE PWM_OUT_5_BIT, true). At this point, initialization of PWM module is complete, then we can enable the PWM signal generator, lighting LED0. • Specific function parameter can be set by reference in front of the library functionswhich are introduced.

More Related