请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号: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);
}