Part Number: TM4C1294NCPDT
Hi,
This is namha.
I want to increase the ADC sampling frequency to over 1Mhz. But the frequency above 600kHz does not increase.
I'm using ADC0 and ADC1 two modules at the same time, I'm using timer0 as a trigger, and I'm working with polling.
And here are some questions.
1. Why does not the sampling frequency increase by more than 1Mhz?
2. I would like to run the ADC clock at 32Mhz using an external oscillator. Can I use the API as shown below?
What does 'ADC_CLOCK_SRC_PLL' mean?
ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 15); // Configure the ADC to use PLL at 480 MHz divided by 15 to get an ADC clock of 32 MHz
ADCClockConfigSet(ADC1_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 15); // Configure the ADC to use PLL at 480 MHz divided by 15 to get an ADC clock of 32 MHz.
3. What does 'ADC_REF_EXT_3V' mean in the code below?
ADCReferenceSet(ADC0_BASE,ADC_REF_EXT_3V)
Below is my code.
------------------------------------------------------------ function ------------------------------------------------------------------------
void ADCInit()
{
uint32_t samplePeriod = 0;
//Initialize ADC
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //ADC0 peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); //ADC1 peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); // ADC Trigger
SysCtlDelay(10);
ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 15); // Configure the ADC to use PLL at 480 MHz divided by 15 to get an ADC
// clock of 32 MHz.
ADCClockConfigSet(ADC1_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 15); // Configure the ADC to use PLL at 480 MHz divided by 15 to get an ADC
// clock of 32 MHz.
SysCtlDelay(10); // Time for the clock configuration to set
//Pins used for ADC channels
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0);
ADCSequenceConfigure(ADC0_BASE, ADC_SEQUENCE_NUMBER, ADC_TRIGGER_TIMER, 0);
ADCSequenceConfigure(ADC1_BASE, ADC_SEQUENCE_NUMBER, ADC_TRIGGER_TIMER, 0);
ADCSequenceStepConfigure(ADC0_BASE, ADC_SEQUENCE_NUMBER, 0, ADC_CTL_D | ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); // Differtial mode, Timer0 Trigger
ADCSequenceStepConfigure(ADC1_BASE, ADC_SEQUENCE_NUMBER, 0, ADC_CTL_D | ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END); // Differtial mode, Timer0 Trigger
ADCHardwareOversampleConfigure(ADC0_BASE, g_ui32AdcOverSamplingNumber);
ADCHardwareOversampleConfigure(ADC1_BASE, g_ui32AdcOverSamplingNumber);
ADCIntClear(ADC0_BASE, ADC_SEQUENCE_NUMBER); // ADC0 interrupt flag clear
ADCIntClear(ADC1_BASE, ADC_SEQUENCE_NUMBER); // ADC1 interrupt flag clear
TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC);
samplePeriod = g_ui32SysClock / 800000; // calculate timerperiod for 500KHz
TimerLoadSet(TIMER0_BASE, TIMER_A, samplePeriod - 1); // sampling frequency
TimerEnable(TIMER0_BASE, TIMER_A);
TimerControlTrigger(TIMER0_BASE, TIMER_A, true);
TimerControlStall(TIMER0_BASE, TIMER_A, true); //Assist in debug by stalling timer at breakpoints
ADCReferenceSet(ADC0_BASE,ADC_REF_EXT_3V); // ADC0 External Reference Voltage setting
ADCReferenceSet(ADC1_BASE,ADC_REF_EXT_3V); // ADC0 External Reference Voltage setting
ADCSequenceEnable(ADC0_BASE, ADC_SEQUENCE_NUMBER);
ADCSequenceEnable(ADC1_BASE, ADC_SEQUENCE_NUMBER);
}
void ADCAcquire_Org(uint32_t ADCDataLength)
{
uint32_t ui32ADCCurrentIndex = 0;
ADCEnable(); // ADC Start
//GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0, GPIO_PIN_0);
for(ui32ADCCurrentIndex=0; ui32ADCCurrentIndex < ADCDataLength/2; ui32ADCCurrentIndex++)
{
ADCIntClear(ADC0_BASE, ADC_SEQUENCE_NUMBER);
ADCIntClear(ADC1_BASE, ADC_SEQUENCE_NUMBER);
while(!ADCIntStatus(ADC0_BASE, ADC_SEQUENCE_NUMBER, 0));
while(!ADCIntStatus(ADC1_BASE, ADC_SEQUENCE_NUMBER, 0));
g_ui16AdcRawData[2*ui32ADCCurrentIndex + 0] = (q15_t)HWREG(ADC0_BASE + ADC_O_SSFIFO3);
g_ui16AdcRawData[2*ui32ADCCurrentIndex + 1] = (q15_t)HWREG(ADC1_BASE + ADC_O_SSFIFO3);
}
//GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0, 0);
ADCDisable(); // ADC Stop
}
void ADCEnable()
{
ADCIntEnable(ADC0_BASE, ADC_SEQUENCE_NUMBER);
ADCIntEnable(ADC1_BASE, ADC_SEQUENCE_NUMBER);
}
void ADCDisable()
{
ADCIntDisable(ADC0_BASE, ADC_SEQUENCE_NUMBER);
ADCIntDisable(ADC1_BASE, ADC_SEQUENCE_NUMBER);
}
------------------------------------------------------------ main------------------------------------------------------------------------
int main(void)
{
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), TM4C129_MAIN_CLK);
FPUEnable();
FPULazyStackingEnable();
.
.
.
.
IntMasterEnable(); // 20190312_LNH, Global Interrupt Enable
while(1)
{
ADCAcquire_Org(FFT_POINTS); // 20190312_LNH
arm_q15_to_float(g_ui16AdcRawData, g_ui32AdcRawData, FFT_POINTS); // 20190312_LNH, integer to float change.
for(i = 0; i < FFT_POINTS; i++) g_ui32AdcRawData[i] = g_ui32AdcRawData[i] * FloatScale; // 20190312_LNH, scaling for integer to float
delay_ms(1); // 20190312_LNH
}