Hello,
I would like to set the ADC correctly.
But I do not understand all the connections in the data sheet:
On page 1389 in the data sheet the following data can be found:
-ADC conversion clock frequency = 16Mhz
-ADC conversion rate = 1Msps
-ADC sample time = 250ns
-ADC conversion time = 1us
-latency from trigger to start of conversion = 2 ADC clocks
How are these data related?
My hardware config looks like this:
void init_SYS_CLOCK()
{
MAP_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL |
SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
MAP_SysCtlDelay(10);
}
void init_WTIMER_5()
{
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER5);
while(!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_WTIMER5));
// WTimer 5A is PD6 and the trigger for adc
MAP_TimerConfigure(WTIMER5_BASE, TIMER_CFG_SPLIT_PAIR |
TIMER_CFG_A_PERIODIC);
// Set ADC sampling frequency to be 44KHz every 22.725uS
MAP_TimerLoadSet(WTIMER5_BASE, TIMER_A, (SysCtlClockGet()/44000) - 1);
// Enable the ADC trigger output for Timer A.
TimerControlTrigger(WTIMER5_BASE, TIMER_A, true);
TimerEnable(WTIMER5_BASE, TIMER_A);
}
void init_uDMA_MIC0()
{
// adc mic setup
// uDMA Channel 14
MAP_uDMAChannelAssign(UDMA_CH14_ADC0_0);
MAP_uDMAChannelAttributeDisable(14,
UDMA_ATTR_ALTSELECT |
UDMA_ATTR_HIGH_PRIORITY |
UDMA_ATTR_REQMASK);
MAP_uDMAChannelControlSet(14 | UDMA_PRI_SELECT,
UDMA_SIZE_16 | UDMA_SRC_INC_NONE |
UDMA_DST_INC_16 | UDMA_ARB_4);
MAP_uDMAChannelControlSet(14 | UDMA_ALT_SELECT,
UDMA_SIZE_16 | UDMA_SRC_INC_NONE |
UDMA_DST_INC_16 | UDMA_ARB_4);
MAP_uDMAChannelAttributeEnable(14, UDMA_ATTR_USEBURST);
}
void init_ADC0()
{
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
while(!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0));
ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC |
ADC_CLOCK_RATE_FULL, 1);
SysCtlDelay(10);
}
void init_ADC0_MIC0()
{
MAP_GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_2);
MAP_IntDisable(INT_ADC0SS0);
MAP_ADCIntDisable(ADC0_BASE, 0);
MAP_ADCSequenceDisable(ADC0_BASE, 0);
//MAP_ADCHardwareOversampleConfigure(ADC0_BASE, 32);
MAP_ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_TIMER, 0);
MAP_ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH5);
MAP_ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH5);
MAP_ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH5);
MAP_ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH5 | ADC_CTL_IE);
MAP_ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ADC_CTL_CH5);
MAP_ADCSequenceStepConfigure(ADC0_BASE, 0, 5, ADC_CTL_CH5);
MAP_ADCSequenceStepConfigure(ADC0_BASE, 0, 6, ADC_CTL_CH5);
MAP_ADCSequenceStepConfigure(ADC0_BASE, 0, 7, ADC_CTL_CH5 |
ADC_CTL_IE | ADC_CTL_END);
// ------------------ //
// Priority Levels
// Priority 4 = 0xE0 ->lower
// Priority 3 = 0x60
// Priority 2 = 0x20
// Priority 1 = 0x00 ->higher
// ------------------ //
MAP_IntPrioritySet(INT_ADC0SS0, 0xE0); // Priority 4 !!!
}
void start_ADC0()
{
recordMusic_ADC0();
MAP_ADCSequenceEnable(ADC0_BASE, 0);
MAP_ADCIntClear(ADC0_BASE, 0);
MAP_ADCSequenceOverflowClear(ADC0_BASE, 0);
MAP_ADCSequenceUnderflowClear(ADC0_BASE, 0);
MAP_ADCSequenceDMAEnable(ADC0_BASE, 0);
MAP_ADCIntEnable(ADC0_BASE, 0);
MAP_IntEnable(INT_ADC0SS0);
}
void recordMusic_ADC0()
{
#ifndef DEBUG_OFF
DEBUG_PC4 = GPIO_PIN_4; // Rec
#endif
if (mic0BuffersStatus[0] == EMPTY)
{
// start primary channel to buffer in ADCBufferForFft0
MAP_uDMAChannelTransferSet(14 | UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
(void *)(ADC0_BASE + ADC_O_SSFIFO0),
&mic0Buffers[0], 1024);
MAP_uDMAChannelEnable(14 | UDMA_PRI_SELECT);
mic0BuffersStatus[0] = FILLING;
#ifndef DEBUG_OFF
DEBUG_PA2 = GPIO_PIN_2; // ADC Start Pri1
#endif
}
if (mic0BuffersStatus[1] == EMPTY)
{
// start alternate channel to buffer in ADCBufferForFft1
MAP_uDMAChannelTransferSet(14 | UDMA_ALT_SELECT,
UDMA_MODE_PINGPONG,
(void *)(ADC0_BASE + ADC_O_SSFIFO0),
&mic0Buffers[1], 1024);
MAP_uDMAChannelEnable(14 | UDMA_ALT_SELECT);
mic0BuffersStatus[1] = FILLING;
#ifndef DEBUG_OFF
DEBUG_PA3 = GPIO_PIN_3; // ADC Start Alt1
#endif
}
#ifndef DEBUG_OFF
DEBUG_PA2 = 0; // ADC Start Pri1
DEBUG_PA3 = 0; // ADC Start Alt1
#endif
}
The CPU clock on 80Mhz.
The ADC clock on 16Mhz.
The ADC conversion rate is at 1Msps.
The WTimer5A is set to 44kHz.
If hardware oversampling is off, how do I calculate my sampling rate now?
I would like to understand the correlations.
And would also be very happy about a few calculation examples.
I just checked my settings with a Logig Analyzer and found out that the timer frequency has no influence on the sampling rate.
Only when I turn on hardware oversampling, I get a low sampling rate.
