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.

[参考译文] TM4C129XNCZAD:ADC 中断采样计时器错误

Guru**** 2424730 points


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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/703645/tm4c129xnczad-adc-interrupt-sampling-timer-error

器件型号:TM4C129XNCZAD

尊敬的  

 当 ADC 处于中断模式时,我没有获得实际输出。 我想以10kHz 的频率对 ADC 采样。 我使用计时器生成中断、请建议我进行任何修改。

/*
main.c
*/
#include "stdbool.h"
#include "stdint.h"
#include "gpio.h"
#include "rom_map.h"
#include "driverlib/sysctL.h"
#include "hw_memmap.h"
#include "crinc/包含





"nectid.h"#mbrand.md.包含



"ng小时


#include "drivers/包含"nech"#brand.md.md.md.md.htm#include "#include "#include "#brand.md.md.htm#include "#include "#include "#tid.md.htm#include "#include "#g小时#include "#include "#tid.dl.md.md.md.md.md.htm#include "#include "#include "#include "#tid.md.md.md.md.md.htm#include "#include "#include "#grech"#include "#tid.md.md.md.md.md.md.md.md.md.md.md.md.md.htm#include

"

#include "driverlib/rom.h"
#include "driverlib/udma.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
//#include "inc/hw_ints.h"

#define GPIO_PA2_SSI0CLK 0x0000080F
#define GPIO_PA3_SSI0FSS 0x00000C0F
#define GPIO_PA4_SSI0TX 0x0000100F
#define GPIO_PA5_SSI0RX 0x0000140F
void MT_SSIConfigure (void);
void MT_ADCConfigure (void);
void Timer_configure (void);
void Interrupt_configure (void);
//void Timer0IntHandler (void);
float DAC_count、value、xval[27];

浮点和、温度、电压、值;
uint32_t pui32ADC0Value[2];
void DAC_LDAC (void);
uint32_t ui32Period1、ui32Period2;
uint32_t ui32SysClock;
uint32_t pui32DataTx;
const double firCoeffs32[26]={

0.00042786716307723429、
0.002919136775687219、
0.0087411768920698726、
0.01728389646188545、
0.023790092406399139、
0.020625746649647263、
0.0026178235631764959、
-0.025784577131922413、
-0.047619527772776261、
-0.039756341015621199、
0.012766667411548112、
0.10310658429302662、
0.20045692369728618、
0.26366156038852501、
0.26366156038852501、
0.20045692369728618、
0.10310658429302662、
0.012766667411548112、
-0.039756341015621199、
-0.047619527772776261、
-0.025784577131922413、
0.0026178235631764959、
0.020625746649647263、
0.023790092406399139、
0.01728389646188545、
0.0087411768920698726、
0.002919136775687219、
0.00042786716307723429、





};
void MT_ADCConfigure()
{
SysCtlPeripheralEnable (SYSCTL_Periph_ADC0);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOK);
GPIOPinTypeADC (GPIO_PORTK_base、GPIO_PIN_1);
ADCSequenceConfigure (ADC0_BASE、3、ADC_TRIGGER_TIMER、0);
ADCSequenceStepConfigure (ADC0_BASE、3、0、ADC_CTL_CH17 | ADC_CTL_IE |
ADC_CTL_END);
ADCSequenceEnable (ADC0_BASE、3);
ADCIntClear (ADC0_BASE、3);
}
void MT_SSIConfigure()
{
SysCtlPeripheralEnable (SYSCTL_Periph_SSI0);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOA);
GPIOPinConfigure (GPIO_PA2_SSI0CLK);
GPIOPinConfigure (GPIO_PA3_SSI0FSS);
GPIOPinConfigure (GPIO_PA4_SSI0TX);
GPIOPinConfigure (GPIO_PA5_SSI0RX);
GPIOPinTypeSSI (GPIO_Porta_base、GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2);
SSIConfigSetExpClk (SSI0_BASE、SysCtlClockGet ()、SSI_FRF_MOTO_MOTO_MODE_3、
SSI_MODE_MASTER、10000、16);
SSIEnable (SSI0_BASE);
}
void Timer_configure ()
{
ROM_SysCtlPeripheralEnable (SYSCTL_Periph_TIMER0);
ROM_TimerConfigure (TIMER0_BASE、TIMER_CFG_PERIODICASE);
ui32Period1 = SysCtlClockGet ();
ui32Period2=(ui32SysClock/10000);
TimerLoadSet (TIMER0_BASE、TIMER_A、ui32Period2 -1);
TimerControlTrigger (TIMER0_BASE、TIMER_A、TRUE);
}
void Interrupt_configure ()
{
ROM_IntEnable (INT_TIMER0A);
ROM_TimerIntEnable (TIMER0_BASE、TIMER_TINA_TIMEOUT);
ROM_IntEnable (INT_ADC0SS3);
ROM_ADCIntEnable (ADC0_BASE、3);
ROM_IntMasterEnable();
ROM_TimerEnable (TIMER0_BASE、TIMER_A);
}
int main (void)
{
int i、k;
float DAC_count、value;
浮点和、温度、电压;
uint32_t ui32SysClock、l;
ui32SysClock = SysCtlClockFreqSet ((SYSCTL_XTAL_25MHz |SYSCTL_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480)、120000000);
MT_ADCConfigure();
timer_configure();
INTERRUPT_CONFIG();
MT_SSIConfigure();
DAC_LDAC ();
for (i=0;i<=26;i++)
{
xval[i]=0;
}


while (1)
{
MAP_GPIOPinWrite (GPIO_PORTB_BASE、GPIO_PIN_5、GPIO_PIN_5);
MAP_GPIOPinWrite (GPIO_PORTF_BASE、GPIO_PIN_3、GPIO_PIN_3);

DAC_count=(sum*8190);
pui32DataTx=DAC_COUNT;
SSIDataPut (SSI0_BASE、pui32DataTx);
while (SSIBusy (SSI0_BASE))
{
}
MAP_GPIOPinWrite (GPIO_PORTB_BASE、GPIO_PIN_5、0);
SSIIntClear (SSI0_BASE、SSI_RXFF);
MAP_GPIOPinWrite (GPIO_PORTB_BASE、GPIO_PIN_5、GPIO_PIN_5);

}

//return 0;
}
void DAC_LDAC ()
{
/// LDAC 信号
MAP_SysCtlPeripheralEnable (SYSCTL_Periph_GPIOB);
MAP_GPIOPinTypeGPIOOutput (GPIO_PORTB_BASE、GPIO_PIN_5);
MAP_GPIOPinWrite (GPIO_PORTB_BASE、GPIO_PIN_5、GPIO_PIN_5);
//复位信号
MAP_SysCtlPeripheralEnable (SYSCTL_Periph_GPIOF);
MAP_GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE、GPIO_PIN_3);
MAP_GPIOPinWrite (GPIO_PORTF_BASE、GPIO_PIN_3、0);
}

void ADC0SS3IntHandler (void)
{

ADCIntClear (ADC0_BASE、3);
ADCSequenceDataGet (ADC0_BASE、3、pui32ADC0Value);
xval[0]=(*pui32ADC0Value*3.3)/4096;



}
void Timer0IntHandler (void)
{
ROM_TimerIntClear (TIMER0_BASE、TIMER_TINA_TIMEOUT);
}

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

    下面是一个简单的示例项目、该项目使用计时器触发 ADC、然后使用 UDMA 将结果复制到缓冲区中。 从 CCS 中选择"File"->"Import"、选择"CCS Project"、"next " 、然后选择"Select archive file"。

    /cfs-file/__key/communityserver-discussions-components-files/908/1667.ADCwDMA.zip

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

    亲爱的 bob、感谢您的回复、因为现在我被 ADC 抽取了、而 ADC 采样速率为10k、我无法看到我的 ADC 输出。 我将应用分为三部分 ADC 读数 DAC 写入和 fir algo。 但在第一部分、我认为 ADC 无法正确获取数据。 我需要你的帮助、因为我已经在这方面做了很多工作。 我正在努力工作。 您能告诉我为什么我在 CCS 中看不到1kHz 的图形功能



    include "stdbool.h"
    #include "stdint.h"
    #include "pin_map.h"
    #include "rom_map.h"
    #include "driverlib/sysctl.h"
    #include "smt/hw_memmap.h"
    #include
    "drivers/包含"drivers/mbrand.dlib"
    
    
    #include "mdg小时
    
    
    
    
    
    
    
    #include "drivers.dlinc/包含"nech"#md.dlinc/包含"drivers.dlib"#def"#br/md.md.md.htm#include "#include "#def"
    #include "nech"#tintrintrink/g小时#include "#include "drivers.md.md.md.md.md.md.htm#def"#include "#include "#def"#include "#include "necnech"#include "#def"#def"#include "necnecnecnecnecnecnecnecnecnech"#br#t.dl.md.md.dl.md.md.md.md.md.md.md.md
    
    
    
    
    
    #include "driverlib/timer.h"
    #include "driverlib/interrupt.h"
    void init_adc (void);
    float 电压;
    uint32_t pui32ADC0Value[2];
    float xval[122]、dac_count;
    void init_timer ();
    
    uint32_t ui32Period;
    uint32_t ui32SysClock;
    uint32_t pui32DataTx;
    静态 uint32_t g_ui32SysTickCount;
    空 Timer0AIntHandler (空)
    {
    //
    //清除计时器中断标志。
    //
    TimerIntClear (TIMER0_BASE、TIMER_TINA_TIMEOUT);
    }
    
    void SysTickIntHandler (空)
    {
    //更新我们的系统节拍计数器。
    G_ui32SysTickCount++;
    }
    
    空 ADCseq0Handler()
    {
    ADCIntClear (ADC0_BASE、0);
    ADCSequenceDataGet (ADC0_BASE、0、pui32ADC0Value);
    Voltag=(* pui32ADC0Value* 3.3)/4096;
    
    }
    
    
    
    /*
    main.c
    */
    int main (void)
    {
    unsigned int i、k;
    
    ui32SysClock = SysCtlClockFreqSet ((SYSCTL_XTAL_25MHz |SYSCTL_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480)、12000000);
    
    MAP_SysCtlPeripheralEnable (SYSCTL_Periph_TIMER0);//启用 TIMER0的时钟
    MAP_SysCtlPeripheralEnable (SYSCTL_Periph_ADC0);//启用 ADC 模块的时钟
    
    MAP_SysCtlPeripheralEnable (SYSCTL_Periph_GPIOK);//启用端口 k 的时钟
    MAP_SysCtlDelay (30);
    
    MAP_SysTickPeriodSet (ui32SysClock / 100000u);//将 SysTic 计数器的周期设置为10us
    map_SysTickIntEnable();
    map_SysTickEnable();
    init_adc();
    init_timer();
    // mt_SSIConfigure();
    // DAC_LDAC ();
    MAP_IntMasterEnable();
    MAP_TimerEnable (TIMER0_BASE、TIMER_A);//开始一切
    
    while (1)
    {
    
    
    
    
    
    
    
    
    
    
    }
    
    
    
    }
    
    void init_timer()
    {
    MAP_TimerConfigure (TIMER0_BASE、TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODICASE);
    //将采样频率设置为16KHz (每隔62.5uS)
    MAP_TimerLoadSet (TIMER0_BASE、TIMER_A、ui32SysClock/320000 -1);//TODO:此处设置定时器装载值
    MAP_TimerControlTrigger (TIMER0_BASE、TIMER_A、TRUE);
    MAP_TimerControlStall (TIMER0_BASE、TIMER_A、TRUE);//通过在断点处停止计时器来帮助调试
    }
    
    void init_adc ()
    {
    GPIOPinTypeADC (GPIO_PORTK_base、GPIO_PIN_1);
    SysCtlDelay (80);
    
    //使用 ADC0序列0为每个定时器周期对通道0采样一次
    ADCClockConfigSet (ADC0_BASE、ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_Half、1);
    
    SysCtlDelay (10);//设置时钟配置的时间
    
    IntDisable (INT_ADC0SS0);
    ADCIntDisable (ADC0_BASE、0);
    ADCSequenceDisable (ADC0_BASE、0);
    //禁用序列后,现在可以安全地加载新的配置参数
    
    ADCSequenceConfigure (ADC0_BASE、0、ADC_TRIGGER_TIMER、0);
    ADCSequenceStepConfigure (ADC0_BASE、0、0、ADC_CTL_CH17| ADC_CTL_END | ADC_CTL_IE);
    ADCSequenceEnable (ADC0_BASE、0);//设置配置后、重新启用序列发生器
    ADCIntClear (ADC0_BASE、0);
    // ADCSequenceDMAEnable (ADC0_BASE、0);
    ADCIntEnable (ADC0_BASE、0);
    IntEnable (INT_ADC0SS0);
    
    } 

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

    好的、我看到您正在运行16MHz PIOSC 的 ADC。 我从另一个线程中了解到、当您施加恒定电压时、您会得到预期结果、但对于1KHz 正弦波、您不会得到预期结果。 您能详细说明吗? 正弦波的振幅是多少? 什么是源阻抗? 结果是什么样的? 对于默认采样时间、源阻抗过高可能是一个问题。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    具有50欧姆阻抗的2V 输入。 以16KHz 采样输入、这是2VINPUT 的正弦波。 我希望从 DAC 获得相同的输出。 我从 ADC 获取输入、然后将其发送到 DAC。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    感谢您的回复、请告诉我。 HO WTO 检查 CCS 中的循环时间计时器值我是指时间相关特性。
    我以16K 的正弦波进行采样。 我能否在 DAC 输出端产生实际波形。 我的意思是在微控制器的 SPI 端口进行简单的 WRT