Answered step by step
Verified Expert Solution
Question
1 Approved Answer
hello sir I am using TI c 2 0 0 0 2 8 3 7 9 D board. ' I would like to create the
hello sir
I am using TI cD board.
I would like to create the content below by combining the two codes in the attachment.
I want ePWM and ePWM to appear when the ADC input comes on
ePWM A and B must appear complementary to each other.
If the ADC input is larger than v PWM duty should increase, and if it is smaller, PWM should decrease.
ADC will be input as a function generator.
###########################################################################
NO code
Continuous DA and AD triggered by ePWM
modified from adcsocepwmcpuc
###########################################################################
Included Files
#include FxProject.h
Globals
volatile struct DACREGS DACPTRx&DacaRegs,&DacbRegs,&DaccRegs;
Uint dacval ;
Defines
#define REFERENCEVDAC
#define REFERENCEVREF
#define DACA
#define DACB
#define DACC
#define REFERENCE REFERENCEVREF
#define DACNUM DACA
filter coefficients
#define BCOEFF e
#define ACOEFF e
Function Prototypes
void ConfigureADCvoid;
void ConfigureEPWMvoid;
void SetupADCEpwmUint channel;
interrupt void adcaisrvoid;
void configureDACUint dacnum;
Defines
#define RESULTSBUFFERSIZE
Globals
Uint AdcaResults;
Uint resultsIndex;
volatile Uint bufferFull;
float y;
float uprev;
void mainvoid
Step Initialize System Control:
PLL WatchDog, enable Peripheral Clocks
This example function is found in the FxDSysCtrlc file.
InitSysCtrl;
Step Initialize GPIO:
This example function is found in the FxDGpio.c file and
illustrates how to set the GPIO to it's default state.
InitGpio; Skipped for this example
Step Clear all interrupts and initialize PIE vector table:
Disable CPU interrupts
DINT;
Initialize the PIE control registers to their default state.
The default state is all PIE interrupts disabled and flags
are cleared.
This function is found in the FxDPieCtrl.c file.
InitPieCtrl;
Disable CPU interrupts and clear all CPU interrupt flags:
IER x;
IFR x;
Initialize the PIE vector table with pointers to the shell Interrupt
Service Routines ISR
This will populate the entire table, even if the interrupt
is not used in this example. This is useful for debug purposes.
The shell ISR routines are found in FxDDefaultIsr.c
This function is found in FxDPieVect.c
InitPieVectTable;
Map ISR functions
EALLOW;
PieVectTable.ADCAINT &adcaisr; function for ADCA interrupt
EDIS;
Configure the ADC and power it up
ConfigureADC;
ConfigureDACDACNUM;
Configure the ePWM
ConfigureEPWM;
Setup the ADC for ePWM triggered conversions on channel
SetupADCEpwm;
Enable global Interrupts and higher priority realtime debug events:
IER MINT; Enable group interrupts
EINT; Enable Global interrupt INTM
ERTM; Enable Global realtime interrupt DBGM
Initialize results buffer
forresultsIndex ; resultsIndex RESULTSBUFFERSIZE; resultsIndex
AdcaResultsresultsIndex;
resultsIndex ;
bufferFull ;
enable PIE interrupt
PieCtrlRegs.PIEIERbit.INTx;
sync ePWM
EALLOW;
CpuSysRegs.PCLKCRbit.TBCLKSYNC ;
take conversions indefinitely in loop
do
start ePWM
EPwmRegs.ETSEL.bit.SOCAEN ; enable SOCA
EPwmRegs.TBCTLbit.CTRMODE ; unfreeze and enter up count mode
while;
ConfigureADC Write ADC configurations and power up the ADC for both
ADC A and ADC B
void ConfigureADCvoid
EALLOW;
write configurations
AdcaRegs.ADCCTLbit.PRESCALE ; set ADCCLK divider to
AdcSetModeADCADCA, ADCRESOLUTIONBIT, ADCSIGNALMODESINGLE;
Set pulse positions to late
AdcaRegs.ADCCTLbit.INTPULSEPOS
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started