Part Number: BOOSTXL-DRV8305EVM
Setup: I am using C2000 28379D launchpad with the booster pack DRV8305EVM to implement my own control algorithms. The launchpad is powered by the EVM (i have removed all the JP1,2,3 jumpers). I use C2000ware for programming the launchpad. I have implemented a chopper using the upper switch of phase-A leg and lower switch of the phase-B leg.
Problem: I am unable to accurately sense DC link voltage of the booster pack (ENGATE is high and nfault led is low ). It shows 4095 instead of the correct value. However, the same program works well when the launchpad is powered by USB and the corresponding pin is connected to VSENPVDD of 8305EVM (ground pins of both the boards are connected).
I would appreciate any help in solving this problem. Please find the program below
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Defines
//
// these are for ADC
#define EX_ADC_RESOLUTION ADC_RESOLUTION_12BIT // or ADC_RESOLUTION_16BIT
#define EX_ADC_SIGNAL_MODE ADC_MODE_SINGLE_ENDED // or ADC_MODE_DIFFERENTIAL
#define TB_CLK DEVICE_SYSCLK_FREQ / 2 // Time base clock is SYCLK / 2
#define PWM_CLK 5000
#define PRD_VAL (TB_CLK / (PWM_CLK * 2))
// these are for EPWM
#define EPWM1_TIMER_TBPRD 2000U
#define EPWM1_CMP 1000U
#define EPWM2_TIMER_TBPRD 2000U
#define EPWM2_CMP 1000U
//
// GLOBALS
//
uint16_t adcAResult_Vdd;
uint16_t interruptCount = 0;
uint16_t loopcount = 0;
//
//Function Prototypes
//
// these are for adc
void initADCs(void);
void initADCSOCs(void);
// these are for EPWM
void initEPWM1(void);
void initEPWM2(void);
__interrupt void epwm1ISR(void);
__interrupt void epwm2ISR(void);
//
// Main
//
void main(void)
{
//
// Initiate device clock and periperals
//
Device_init();
//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
//Initialize the PIE vector table with pointers to the shell interrupt Interrupt Service Routines (ISR)
//
Interrupt_initVectorTable();
//
// Set up ADCs, initializing the SOCs to be triggered by software
//
initADCs();
initADCSOCs();
//
// Enable an GPIO output on GPIO124 to clear the ENGATE on booster pack
//
GPIO_setPadConfig(124, GPIO_PIN_TYPE_PULLUP); // Enable pullup on GPIO6
GPIO_writePin(124, 1); // Load output latch
GPIO_setPinConfig(GPIO_124_GPIO124); // GPIO124 = GPIO124
GPIO_setDirectionMode(124, GPIO_DIR_MODE_OUT); // GPIO124 = output
DEVICE_DELAY_US(10000);
//
// Interrupts that are used in this example are re-mapped to ISR functions
// found within this file
//
Interrupt_register(INT_EPWM1, &epwm1ISR);
Interrupt_register(INT_EPWM2, &epwm2ISR);
//
// Configure GPIO0/1, GPIO2/3, and GPIO4/5 as ePWM1A/1B, ePWM2A/2B and ePWM3A/3B
//
GPIO_setPadConfig(0, GPIO_PIN_TYPE_STD);
GPIO_setPinConfig(GPIO_0_EPWM1A);
/*GPIO_setPadConfig(1, GPIO_PIN_TYPE_STD);
GPIO_setPinConfig(GPIO_1_EPWM1B);*/
/*GPIO_setPadConfig(2, GPIO_PIN_TYPE_STD);
GPIO_setPinConfig(GPIO_2_EPWM2A);*/
GPIO_setPadConfig(3, GPIO_PIN_TYPE_STD);
GPIO_setPinConfig(GPIO_3_EPWM2B);
//
// Disable sync(Freeze clock to PWM as well)
//
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
initEPWM1();
initEPWM2();
//
// Enable sync and clock to PWM
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
// Enable ePWM interrupts
//
Interrupt_enable(INT_EPWM1);
Interrupt_enable(INT_EPWM2);
//
// Enable Global Interrupt (INTM) and real time interrupt (DBGM)
//
EINT ;
ERTM ;
//
// Loop indefinitely
//
while(1)
{
//
// Convert, wait for completion, and store results
//
ADC_forceSOC(ADCA_BASE, ADC_SOC_NUMBER0);
//
//Wait for ADCA to complete, then acknowledge flag
//
while(ADC_getInterruptStatus(ADCA_BASE,ADC_INT_NUMBER1)==false)
{
}
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
//
// store results
//
adcAResult_Vdd = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
if(loopcount > 8000)
{
ESTOP0;
loopcount = 0;
}
loopcount = loopcount + 1;
}
}
// End of main
void initADCs(void)
{
//
// Set ADCCLK divider to /4
//
ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);
//
// Set resolution and signal mode (see #defines above) and load corresponding trims.
//
ADC_setMode(ADCA_BASE, EX_ADC_RESOLUTION, EX_ADC_SIGNAL_MODE);
//
// Set pulse positions to late
//
ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);
//
// Powerup the ADCs and then delay for 1 ms
//
ADC_enableConverter(ADCA_BASE);
DEVICE_DELAY_US(1000);
}
void initADCSOCs(void)
{
//
// configure SOCs of ADCA
#if(EX_ADC_RESOLUTION == ADC_RESOLUTION_12BIT)
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN3, 15); // A_v
#elif(EX_ADC_RESOLUTION == ADC_RESOLUTION_16BIT)
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_SW_ONLY,ADC_CH_ADCIN3,64);
#endif
//
// set SOC0 to set the interrupt 1 flag. Enable the interrupt and make sure its flag is cleared.
//
ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);
ADC_enableInterrupt(ADCA_BASE,ADC_INT_NUMBER1);
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
}
//
// initEPWM1 - Configure ePWM1
//
void initEPWM1()
{
//
// Set-up TBCLK
//
EPWM_setTimeBasePeriod(EPWM1_BASE, EPWM1_TIMER_TBPRD);
EPWM_setPhaseShift(EPWM1_BASE, 0U);
EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);
// code for SYNC
EPWM_setSyncOutPulseMode(EPWM1_BASE, EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO);
//
// Set Compare values
//
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM1_CMP);
//EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_B, EPWM1_MAX_CMPB);
//
// Set-up counter mode
//
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP_DOWN);
EPWM_disablePhaseShiftLoad(EPWM1_BASE);
EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1);
//
// Set-up shadowing
//
EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_A,
EPWM_COMP_LOAD_ON_CNTR_ZERO);
/*EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_B,
EPWM_COMP_LOAD_ON_CNTR_ZERO);*/
//
// Set actions
//
EPWM_setActionQualifierAction(EPWM1_BASE,
EPWM_AQ_OUTPUT_A,
EPWM_AQ_OUTPUT_HIGH,
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
EPWM_setActionQualifierAction(EPWM1_BASE,
EPWM_AQ_OUTPUT_A,
EPWM_AQ_OUTPUT_LOW,
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
/*EPWM_setActionQualifierAction(EPWM1_BASE,
EPWM_AQ_OUTPUT_B,
EPWM_AQ_OUTPUT_HIGH,
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB);
EPWM_setActionQualifierAction(EPWM1_BASE,
EPWM_AQ_OUTPUT_B,
EPWM_AQ_OUTPUT_LOW,
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB);*/
//
// Intrrupt where we will change the compare values
// select INT on TIme base counter zero event,
// Enable INT, generate INT on 3rd event
//
EPWM_setInterruptSource(EPWM1_BASE, EPWM_INT_TBCTR_ZERO);
EPWM_enableInterrupt(EPWM1_BASE);
EPWM_setInterruptEventCount(EPWM1_BASE, 3U);
}
//
// initEPWM2 - Configure ePWM2
//
void initEPWM2()
{
//
// Set-up TBCLK
//
EPWM_setTimeBasePeriod(EPWM2_BASE, EPWM2_TIMER_TBPRD);
EPWM_setPhaseShift(EPWM2_BASE, 0U);
EPWM_setTimeBaseCounter(EPWM2_BASE, 0U);
// code for SYNC
EPWM_setCountModeAfterSync(EPWM2_BASE, EPWM_COUNT_MODE_UP_AFTER_SYNC) ;
EPWM_setSyncOutPulseMode(EPWM2_BASE, EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO);
//
// Set Compare values
//
//EPWM_setCounterCompareValue(EPWM2_BASE, EPWM_COUNTER_COMPARE_A, EPWM2_CMP);
EPWM_setCounterCompareValue(EPWM2_BASE, EPWM_COUNTER_COMPARE_B, EPWM2_CMP);
//
// Set-up counter mode
//
EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_UP_DOWN);
EPWM_enablePhaseShiftLoad(EPWM2_BASE);
EPWM_setClockPrescaler(EPWM2_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1);
//
// Set-up shadowing
//
/*EPWM_setCounterCompareShadowLoadMode(EPWM2_BASE, EPWM_COUNTER_COMPARE_A,
EPWM_COMP_LOAD_ON_CNTR_ZERO);*/
EPWM_setCounterCompareShadowLoadMode(EPWM2_BASE, EPWM_COUNTER_COMPARE_B,
EPWM_COMP_LOAD_ON_CNTR_ZERO);
//
// Set actions
//
/*EPWM_setActionQualifierAction(EPWM2_BASE,
EPWM_AQ_OUTPUT_A,
EPWM_AQ_OUTPUT_HIGH,
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
EPWM_setActionQualifierAction(EPWM2_BASE,
EPWM_AQ_OUTPUT_A,
EPWM_AQ_OUTPUT_LOW,
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);*/
EPWM_setActionQualifierAction(EPWM2_BASE,
EPWM_AQ_OUTPUT_B,
EPWM_AQ_OUTPUT_HIGH,
EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB);
EPWM_setActionQualifierAction(EPWM2_BASE,
EPWM_AQ_OUTPUT_B,
EPWM_AQ_OUTPUT_LOW,
EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB);
//
// Intrrupt where we will change the compare values
// select INT on TIme base counter zero event,
// Enable INT, generate INT on 3rd event
//
EPWM_setInterruptSource(EPWM2_BASE, EPWM_INT_TBCTR_ZERO);
EPWM_enableInterrupt(EPWM2_BASE);
EPWM_setInterruptEventCount(EPWM2_BASE, 3U);
}
//
// epwm1ISR-- ePWM 1 ISR
//
__interrupt void epwm1ISR(void)
{
//
// Clear INT flag for this timer
//
EPWM_clearEventTriggerInterruptFlag(EPWM1_BASE);
//
// Acknowledge interrupt group
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
}
//
// epwm2ISR-- ePWM 2 ISR
//
__interrupt void epwm2ISR(void)
{
//
// Clear INT flag for this timer
//
EPWM_clearEventTriggerInterruptFlag(EPWM2_BASE);
//
// Acknowledge interrupt group
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
}