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.

[参考译文] TM4C123GH6PM:TM4C123XXX ADC 序列3问题

Guru**** 2613915 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/773463/tm4c123gh6pm-tm4c123xxx-adc-sequence-3-issues

器件型号:TM4C123GH6PM

我一直在尝试使用由计时器触发的序列3对 ADC1进行编程。  代码适用于序列0 (采样数8、FIFO 深度)、但是当我尝试将其更改为序列3时、它永远不会起作用。 我尝试调试、设置断点、对于断点、我可以对64个数据进行采样、但是、当我尝试全速运行时、它永远不起作用。 这是 SS3的代码。  我还在使用 FreeRTOS。  

#include 
#include 





















include "inc/hw_memmap.h"#include "inc/hw_ints.h"#include "driverlib/rom.h"#include "driverlib/rom_map.h"#include "driverlib/rtme.h"#include "driverlib/pintrat.h"#include "driverlib.mdg小时#include "#def"#t#t#def"#def_rteg.h"#include "#t.trin.mdit_rtme.h #include "#include "#def"#def"#def_rtme.t#include "#include "#def"#def"#trigg小时#include "#def"#t#def"#def"#def_rtme.t#include "#t#t#def"#def"#def_rtme.t#include "#include "#def"#def"#t#t#t#t#t#t#t#t#t#t#t.in.in.in.in.in.in.in.integr.in.md.md.md.dl.md.md.






compl_t;

extern void unDec2BCD (uint32_t Hex、uint8_t *解码、uint8_t NDigits);

extern void cr4_FFT_64_STM32 (complex_t *填充、complex_t *数据、uint32_t numberofSysPoints);

extern uint32_t


= uint32_t 静态/uint32_t;buffer32_t = uint32;uint2个 uint2个 uint块/uint32 uintuintuintuint2个静态缓冲区/ uint2个 uintt_t 缓冲区/ uintuint32位 uintuint2个 uintuint2个 uint2个 uintuintuintuintuint2个 uintuint2
//当前 ADC 64点采样存储器组 adcbuff0或 adcbuff1

// extern xSemaphoreHandle g_pLCDSemaphore;
extern xQueueHandle g_pLCDQueue;
#define ADCBATCHSKSTACKSIZE 1024 //栈大小(以字表示


) volatile static static uint32_t translack;exuint8
uint_digit
32 uintut intrack

2;exvolatile unt intratile unt intrack uint8 uintuintuintuint8 uintuintuint32




//牛顿的方法
// s 是一个整数
// sqrt (s)是一个整数
uint32_t sqrtint (uint32_t s){
uint32_t;// t t t 将成为 s
int n;//循环计数器以确保它停止运行
t = s/10+1;//初始猜测
(n = 16- n); n){//保证完成
t =((t*t+s)/t)/2;
}
返回 t;
}

//存储延迟处理并可引用的 ADCBATCH_TASK 的句柄*/

TaskHandle_t xADCBatchTaskHandler = NULL;


void ADC1Seq3_Handler (void){
static Handle_t = ADCK_Intrait

0
;void = ADCK_0;task_Intrakt_t_tle_tle_tle_task_t.t =空

ADCSequenceDataGet (ADC1_base、3、(uint32_t *)缓冲器);

Buffer +=1;
idx++;
if (idx=8)
{
idx=0;
//切换到内存缓冲区2进行 ADC 采样
if (bufferbank =0)
{
bufferbank = 1;
Buffer = adcrom1;
}
else
{
bufferbank =
adctif0;

}
// pF3 ^=(bufferbank =(timer1
)
、timer1)

;timereTaskWencheWench/r 1;timereTimer1 (timer1)
、timer1)、timereWenchemonet1、timer1 (timer1);

}
}

#define BANK0 0x00
#define BANK1 0x01

#define true 1
#define false 0
//*********
//
//此任务读取64点采样值并执行 FFT。
////
*****************
void
ADCBatchTask (void *pvParameters)
{

complex_t x[64]、y[64];
int16_t *pdata;
int16_t *pbkdata;
int32_t Real、imag;

uint32_t mag[32]; // FFT 功率频谱幅度

uint8_t i;
uint32_t maxmag;
uint32_t display = true;
struct LCDItem LCDMessage;
//
循环永远。
//
while (1)
{

// xSemaphoreTake (g_pADCBATCHSemaphore、portMAX_DELAY);
ulTaskNotifyTake (pdTRUE、portMAX_DELAY);
//等待将信标发布 ADC 64点采样
if (bufferbank = 1)//最后一个内存组




(pdt_intbt = 1
);//等待数据1)= pbt = 1 (bt)


//保存(
i=0;i<64;i++)
{
x[i].Real =(* pbkdata)-2048的 pdata 副本;//删除 DC bias 1/2 3.3V
x[i].imag = 0;
pbkdata = pbkdata+2;// adcbuff0 32位、pdata 是64位





、ttimer2;ttimert = 64位、ttimert = 64、t1
;ttimert = 64、timert = 64、timert = t1、t1、t1、ttimer1、t1、t1、timer1、timer1、t1、timer1、t1、t1、timer1、t1、timer1、t1、timer1、timer1 //从64点完成到 FFT 计算完成的 FFT 延迟
PF3 ^=(1U<<3);

for (i=0;i<32;i++)











{Real = y[i].Real;imag = y[i].imag;mag[i]= sqrtint (ree*ree+imag);{max[i]=mag+=mag+=mag+=mag+=mag+=mag+<max[i]=mag=mag+=mag+=mag=mag+<ma*ma*ma=1]<mag+<mag+<mag>mag+<mag+<mag>mag+<mag<ma


}

if (display=true){
LCDMessage.lcdcmd = 2;
LCDMessage.dxmin=0;LCDMessage.dxmax = 63;LCDMessage.dymin=0;LCDMessage.dymax=4095;
LCDMessage.sxmin=0;LCDMessage.sxmax = 127;LCDMessage.symin=0;LCDMessage.symax = 79;
LCDMessage.dxy =(uint32_t *) pdata;
xQueueSend (g_pLCDQueue、&LCDMessage、portMAX_delay);

LCDMessage.lcdcmd = 4;
LCDMessage.dxmin=0;LCDMessage.dxmax = 31;LCDMessage.dymin=0;LCDMessage.dymax=maxmag;// 2^32-1对于 FFT
LCDMessage.sxmin=0;LCDMessage.sxmax = 127;LCDMessage.symin=90;LCDMessage.symax =
dCDMag;LCDMessage.symax = d159;LCDMessage.symag = dCDxy;
xQueueSend (g_pLCDQueue、&LCDMessage、portMAX_DELAY);
}
if (displaymode == OneShot){
display = false;
}
else
{
display = true;
}


// IntDisable (INT_ADC1SS0); // OneShot display

}
}//


fs - 400-8000Hz 高达8kHz,
// intelNum - ADC1通道编号 channelNum = 3
//缓冲区-要采样的数据缓冲
区// NumberOfSamples -样本数=仅64点
//
uint32_t ADCBatchTaskInit (void){

uint32_t period
;

//将全局指针设置为指向 funciton
Buffer 传递的数组= adcbuff0;

//

// ADC0和 Porte 已经在以前的函数中被启用

//必须启用 ADC0外设才能使用。
//
SysCtlPeripheralEnable (sysctl_Periph_ADC1);

//
对于此示例,ADC0与端口 E 上的 AIN0、AIN1、AIN2、AIN3一起使用。
//您的器
件上使用的实际端口和引脚可能不同,请参阅//数据表以了解更多信息。 GPIO 端口 E 需要启用
//以便可以使用这些引脚。
// TODO:将其更改为您正在使用的 GPIO 端口。
//
// SysCtlPeripheralEnable (SYSCTL_Periph_GPIOE);

//
检查是否启用了外设访问。
//
// while (!SysCtlPeripheralReady (SYSCTL_Periph_GPIOE))
//{
//}

//
//选择这些引脚的模拟 ADC 功能。
//请查阅数据表以查看每个引脚分配的函数。
// TODO:更改此选项以选择您正在使用的端口/引脚。
//

GPIOPinTypeADC (GPIO_Porte _BASE、GPIO_PIN_0);// AIN3 PE0 - AIN3


//按照第818页的步骤数据表
// 1)禁用 ADC1的采样序列0
// ADCSequenceDisable (ADC1_base、0);
ADCSequenceDisable (ADC1_base、3);

//2)配置采样序列的触发事件0
//从 Lab3部分3a 中为优先级较低的中断序列0启用 ADC0
// ADC0配置(ADC1_base、0、ADC_TRIGGER_TIMER、3);
ADCSequenceConfigure (ADC1_base、 3、ADC_TRIGGER_TIMER、3);
//4)对于采样序列中的每个采样(总共8个采样)、确保正确的输入源
// ADCSequenceStepConfigure (ADC1_base、3、0、ADC_CTL_CH3);
// for (i = 0;i < 7;i++)、
ADC1_base (ADC1_Configure、ADC1_BASE);// ADC_CTL_CH3);
//}

// 5)对于最后一个、END 位被置位且 IE 被使能(中断)
// ADCSequenceStepConfigure (ADC1_base、0、7、ADC_CTL_CH3 | ADC_CTL_END | ADCNC1_STEEx


(ADC1_BASE、0、ADC1_CTL_0)| ADC1_ENCH 0、ADCK_MASK (ADCK_0)| ADCK_0、ADCK_ENCH 3、ADCK_END | ADCK_0
//由于 ADC 采样序列0
而产生的中断 ADCIntEnableEx (ADC1_base、ADC_INT_SS3);//由于 ADC 采样序列0而产生的中断

//或 ADCIntEnable (ADC1_base、0);
//7)启用 ADCACTSS 寄存器中的采样序列逻辑 ASEN0位
// ADCIntRegister (ADC0 _base、ADC0)
;ADCIntHandler (ADC0)寄存器(ADC0 _base、ADC0) ADC1Seq3_Handler );

// ADCSequenceEnable (ADC1_BASE,0);
ADCSequenceEnable (ADC1_BASE,3);

//
// Timer0外设必须启用才能使用。
//
SysCtlPeripheralEnable (sysctl_Periph_TIMER0);

//针对配置
TimerDisable (TIMER0_BASE、TIMER_A)禁用 Timer0A;

//配置为16位定时器并触发 ADC 转换
// TimerConfigure (TIMER0_BASE、TIMER_Trigger_SPLIT | TIMER_CFG_A)
;//此处配置 TIMER0_BASE (TIMER0_BASE)/ TIMERCFG_TIMER
Timer_A、true);

//

//// TODO:将此配置为根据输入的频率计算加载值
//

/////////period = g_ui32SysClock /400;// 400Hz
period =(uint32_t) g_ui32SysClock /25; // 400Hz
//测试5000Hz 良好
//测试8000Hz 良好
//测试900Hz 9kHz 不工作
//测试10000Hz 10kHz 不工作,时间
负荷集过快(TIMER0_BASE、TIMER_A、PERIOD-1);
时间启用(TIMER0_BASE、 Timer_A);

ADCIntClear (ADC1_base、0);
TimerIntClear (TIMER0_BASE、TIMER_TINA_TIMEOUT);


// IntPrioritySet (INT_ADC1SS0、(3<<5));
IntPrioritySet (INT_ADC1SS3、(3<5));

// IntEnable (INT_ADC1SS0);
IntEnable (INT_ADC1SS3);
// TimerIntEnable (TIMER0_BASE、 Timer_A);//这可能不需要、TIMER0A 中断不需要。
// if (xTaskCreate (ADCBatchTask、(const portCHAR *)"ADC 批处理"、
// ADCBATCHSTACKSIZE、


NULL、tskIDLE_PRIORITY +// Priority_ADCBATCH_TASK、NULL)!= pdPASS) if (xTaskCreate (ADCBatchTask、(conCCATLE_PRIREF
)+ ADCCSTACK!/ADCCSTACK_TASK 任务处理程序





+ ADCCACK!)+ ADCCSTACK 任务处理

程序!// ADCCSTACK 任务处理程序!// ADCCACK_PRIZE!
//
return (0);
} 

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Guoping、

    我看到您的代码有两个问题。

    1)

    我看不到您在以下位置初始化 GPIO 端口 E:

    SysCtlPeripheralEnable (SYSCTL_Periph_GPIOE); 

    您可能需要在 ADC 初始化代码中取消注释、除非在其他地方调用。

    2)  

    在两个位置、您没有更新 ADCIntClear 以清除序列3中断:

    ADCIntClear (ADC1_BASE、0); 

    应该是

    ADCIntClear (ADC1_BASE、3); 

    查看这些修复是否解决了问题。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    谢谢、我在 ADC 代码中让端口 E 初始化、
    ADCIntClear (ADC1_base、3);这个有助于我们解决问题。 现在我了解第二个参数是 ADC 序列源、但在 Tiva 外设库中没有很清楚地解释。

    非常感谢、
    古平