This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好!
我正在尝试达到 TM4C1294NCPDT 板上 ADC 的上述1MHz 采样率。 但是、对于每个通道、我可以达到的所有频率都高达50kHz (我使用的是4个通道)。 我正在使用计时器来触发 ADC 序列并获取数据。 我还在计时器中断之间进行了一些处理。
每当我尝试将采样率设置为大于50kHz 时、代码将不起作用、当我在 CCS 中使用"Expression"选项卡观察变量时、代码会给出一些垃圾值。
请告诉我出错的地方以及如何达到最大采样率、因为这对我很有帮助。 我已随附以下代码。
此致、
Sourav
#include #include #include #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "driverlib/interrupt.h" #include "driverlib/adc.h" #include "driverlib/gpina.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #define #t_win_t#define #define #t#t#tine_tide_t#define #define #define #driverlib/t#t#t#t#define #t_win_t#t#t#t#define #define #include "t#t#t#tin.000#define #define #define #include "driverlib_win_win_triggotrupt.h uint32_t pui32ADC0Value[TOT_CHN]; uint32_t cnt [TOT_CHN]; volatile uint32_t read_data[TOT_CHN][120];volatile uint32_t ci = 0; volatile uint16_t UB、l、m、p = 0;volatile uint16_t lb = 100-low-win; volatile uint16_t y[TOT_CHN]={100、100、100、100};volatile uint16_t k[TOT_CHN]; 易失性 uint32_t saved_data[TOT_CHN][100];易失性 uint32_t sample [TOT_CHN]; volatile bool read[TOT_CHN]={true、true、true、true}; //volatile UINT32_t write = 0; int main (void) { uint32_t ui32SysClock; ui32SysClock = SysCtlClockFreqSet ((SYSCTL_XTAL_25MHz | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480)、120000000); SysCtlPeripheralEnable (SYSCTL_Periph_TIMER0); // SysCtlPeripheralReset (SYSCTL_Periph_ADC0); SysCtlPeripheralEnable (SYSCTL_Periph_ADC0); SysCtlPeripheralEnable (SYSCTL_Periph_GPIOE); // SysCtlPeripheralEnable (SYSCTL_Periph_GPION); GPIOPinTypeADC (GPIO_Porte _BASE、GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0); ADCClockConfigSet (ADC0_BASE、ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL、30); // GPIOPinTypeGPIOOutput (GPIO_PORTN_BASE、GPIO_PIN_2); ADCSequenceConfigure (ADC0_BASE、1、ADC_TRIGGER_TIMER、0); // ADCequenceConfigure (ADC0_BASE、 1、ADC_TRIGGER_AUSE_0); TimerConfigure (TIMER0_BASE、TIMER_CFG_PERIODICASE); ADCSequenceStepConfigure (ADC0_BASE、1、0、ADC_CTL_CH0); ADCSequenceStepConfigure (ADC0_BASE、1、1、ADC_CTL_CH1); ADCSequenceStepConfigure (ADC0_BASE、1、2、ADC_CTL_CH2); ADCSequenceStepConfigure (ADC0_BASE、1、3、ADC_CTL_CH3 | ADC_CTL_IE | ADC_CTL_END); TimerLoadSet (TIMER0_BASE、TIMER_A、ui32SysClock/SAMPLING_RATE); TimerControlTrigger (TIMER0_BASE、TIMER_A、TRUE); IntMasterEnable(); TimerIntEnable (TIMER0_BASE、TIMER_TINA_TIMEOUT); IntEnable (INT_TIMER0A); ADCSequenceEnable (ADC0_BASE、1); ADCIntClear (ADC0_BASE、1); TimerEnable (TIMER0_BASE、TIMER_A); //SysCtlDelay (ui32SysClock/6); while (1) { //GPIOPinWrite (GPIO_PORTN_BASE、GPIO_PIN_2、4); for (l=0;l =TOT_WIN){k[l]=0;} } for (l=0;l =500 && read[l]=true){ M=LB;Read[l]=false;y[l]=0;采样[l]=CI; for (p=0;p<10;p++){ saved_data[l][k[l]=read_data[l][m+1];k[l]++; M++; if (m>=100){m=0;} } CNT[l]++; } } if (UB>=100){UB=0;} if (lb>=100){lb=0;} if (Ci >100000){Ci = 0;} //SysCtlDelay (200000); //GPIOPinWrite (GPIO_PORTN_BASE、GPIO_PIN_2、1); //SysCtlDelay (200000); } } void Timer0IntHandler (void) { //GPIOPinWrite (GPIO_PORTN_BASE、GPIO_PIN_2、4); UB++;LB++;CI++; TimerIntClear (TIMER0_BASE、TIMER_TINA_TIMEOUT); //ADCProcessorTrigger (ADC0_BASE、1); while (!ADCIntStatus (ADC0_BASE、1、false) { } ADCIntClear (ADC0_BASE、1); ADCSequenceValue DataGet (ADC0_BASE、1、pui32ADC00); for (l=0;<TOT_CHN;l++){ read_data[l][ub]=pui32ADC0Value[l]; 读取[l]=true; } for (l=0;<TOT_CHN;l++){ if (y[l])
卡在"while"循环中的问题是、您使用计时器启动 ADC 并生成中断。 在计时器中断例程中、您需要等待四个 ADC 转换完成。 相反、使用计时器来启动 ADC、但使用 ADC 序列的最后一步来生成中断。 我附加了一个使用计时器启动 ADC 的示例。 由于它使用 UDMA 而不是 CPU 来读取 ADC、因此它会更加复杂。 也许它会对您有所帮助。
/cfs-file/__key/communityserver-discussions-components-files/908/7380.ADCwDMA.zip