How do i get simple pwm at every epwm pins and should able to get different duty cycle only by changing resister value. Give me an example of this.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
How do i get simple pwm at every epwm pins and should able to get different duty cycle only by changing resister value. Give me an example of this.
check controlSUITE for PWM examples. You may have to read the ePWM pdf to understand the registers of the module.
Hope this help
Gastón
Abhi refer this pdf document:0412.C2000_launchpad_basics.pdf
This will give you step by step project creation details.
Regards,
Gautam
What happened with the "search the forum"? Search the internet?
There is a lot of people that asked "similar" questions in this forum in the past.
Gastón
Hello Gautam.
I appreciate your response to my problems....
Now i want your help in generating PWM on pin EPWM-3A and EPWM-3B.
For that i made changes in example 'AsymmetricPWM'
I replaced 2 by 3 at every place in the code, File name of this code is AsymmetricPWM-main.c.
I am copying whole code below.
I want your kind attention that i made changes only in file 'Asymmetric-main.c' rest are same.
Problem: Program debuging run correctly, It didn't show any error. But when i run this program there is no any output on any pin. CRO shows only noise signals. Please guide me.
I am using ccsv6. and my device is C2000, Piccolo control stick TMS320f28027.
Program code is as follows.......
//------------------------------------------------------------------------------------
// FILE: AsymmetricPWM .C
// (Up, Single Edge Asymmetric Waveform, With Independent Modulation
// on EPWM2A and EPWM2B)
//
// Description: This program sets up the EV TIMER2 to generate complimentary
// PWM waveforms. The user can then observe the waveforms using an scope from
// ePWM2A and ePWM2B pins.
// - In order to change the PWM frequency, the user should change
// the value of"period".
// - The duty-cycles can independently be adjusted by changing compare
// values (duty_cycle_A & duty_cycle_B) for ePWM2A and ePWM2B.
// - For further details, please search for the SPRU791.PDF
// (TMS320x28xx, 28xxx Enhanced Pulse Width Modulator Module) at ti.com
//
// Target: TMS320F2802x or TMS320F2803x families (Piccolo)
//
//------------------------------------------------------------------------------------
// $TI Release:$ V1.1
// $Release Date:$ 26 Oct 2009 - BL
//------------------------------------------------------------------------------------
//
// PLEASE READ - Useful notes about this Project
// Although this project is made up of several files, the most important ones are:
// "AsymmetricPWM .c", this file
// - Application Initialization, Peripheral config
// - Application management
// - Slower background code loops and Task scheduling
// "AsymmetricPWM-DevInit_F28xxx.c"
// - Device Initialization, e.g. Clock, PLL, WD, GPIO mapping
// - Peripheral clock enables
// The other files are generally used for support and defining the registers as C
// structs. In general these files will not need to be changed.
// "F28027_RAM_AsymmetricPWM.CMD" or "F28027_FLASH_AsymmetricPWM.CMD"
// - Allocates the program and data spaces into the device's memory map.
// "DSP2802x_Headers_nonBIOS.cmd" and "DSP2802x_GlobalVariableDefs.c"
// - Allocate the register structs into data memory. These register structs are
// defined in the peripheral header includes (DSP2802x_Adc.h, ...)
//
//----------------------------------------------------------------------------------
#include "PeripheralHeaderIncludes.h"
#include "DSP2802x_EPwm_defines.h" // useful defines for initialization
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// FUNCTION PROTOTYPES
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void DeviceInit(void);
void InitFlash(void);
void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// VARIABLE DECLARATIONS - GENERAL
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Used for running BackGround in flash and the ISR in RAM
extern Uint16 RamfuncsLoadStart, RamfuncsLoadEnd, RamfuncsRunStart;
Uint16 duty_cycle_A=30000; // Set duty 50% initially
Uint16 duty_cycle_B=30000; // Set duty 50% initially
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// MAIN CODE - starts here
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void main(void)
{
//=================================
// INITIALISATION - General
//=================================
DeviceInit(); // Device Life support & GPIO mux settings
// Only used if running from FLASH
// Note that the variable FLASH is defined by the compiler (-d FLASH)
#ifdef FLASH
// Copy time critical code and Flash setup code to RAM
// The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
// symbols are created by the linker. Refer to the linker files.
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
InitFlash(); // Call the flash wrapper init function
#endif //(FLASH)
//-------------------------------------------------------------
#define period 60000
// Time-base registers
EPwm3Regs.TBPRD = period; // Set timer period, PWM frequency = 1 / period
EPwm3Regs.TBPHS.all = 0; // Time-Base Phase Register
EPwm3Regs.TBCTR = 0; // Time-Base Counter Register
EPwm3Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; // Set Immediate load
EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count-up mode: used for asymmetric PWM
EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm3Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;
EPwm3Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwm3Regs.TBCTL.bit.CLKDIV = TB_DIV1;
// Setup shadow register load on ZERO
EPwm3Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm3Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm3Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero
EPwm3Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero
// Set Compare values
EPwm3Regs.CMPA.half.CMPA = duty_cycle_A; // Set duty 50% initially
EPwm3Regs.CMPB = duty_cycle_B; // Set duty 50% initially
// Set actions
EPwm3Regs.AQCTLA.bit.ZRO = AQ_SET; // Set PWM2A on Zero
EPwm3Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Clear PWM2A on event A, up count
EPwm3Regs.AQCTLB.bit.ZRO = AQ_CLEAR; // Set PWM2B on Zero
EPwm3Regs.AQCTLB.bit.CBU = AQ_SET; // Clear PWM2B on event B, up count
//=================================
// Forever LOOP
//=================================
// Just sit and loop forever:
// No interrups needed in this example.
// PWM pins can be observed with a scope.
for(;;)
{
EPwm3Regs.CMPA.half.CMPA = duty_cycle_A; // Add duty_cycle_A to watch window
EPwm3Regs.CMPB = duty_cycle_B; // Add duty_cycle_B to watch window
} // and change its value to see the effect
}
Gautam i have mechanical backgroung, so facing so many problems to operate this device. Please tell me the step by step procedure, so that it may become easy for me