Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE
Tool/software: Code Composer Studio
I wanted to set the ADC sampling frequency to 1MHz, I used c2000ware driverlib do it, but I only got 500KHz.
Then, I tried to fix it by changing the TBPRD(use EPWM5_SOCA as a trigger), however, no matter what TBPRD I chose, the sampling can't surpass 500KHz.
void ADC_Init(void)
{
ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);
ADC_setMode(ADCA_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);
ADC_enableConverter(ADCA_BASE);
DEVICE_DELAY_US(1000);
}
void ADC_SOC_Init(void)
{
ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM5_SOCA,ADC_CH_ADCIN0, 15);
ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);
ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
}
void ADC_EPWM_Init(void)
{
EPWM_disableADCTrigger(EPWM5_BASE, EPWM_SOC_A);
EPWM_setADCTriggerSource(EPWM5_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_U_CMPA);
EPWM_setADCTriggerEventPrescale(EPWM5_BASE, EPWM_SOC_A, 1);
EPWM_setCounterCompareValue(EPWM5_BASE, EPWM_COUNTER_COMPARE_A, 50);
EPWM_setTimeBasePeriod(EPWM5_BASE, 100);
// Freeze the counter
EPWM_setTimeBaseCounterMode(EPWM5_BASE, EPWM_COUNTER_MODE_STOP_FREEZE);
EPWM_enableADCTrigger(EPWM5_BASE, EPWM_SOC_A);
EPWM_setTimeBaseCounterMode(EPWM5_BASE, EPWM_COUNTER_MODE_UP);
}