dsp28335ADC采样程序
时间: 2023-10-28 12:06:37 浏览: 158
以下是一个基本的dsp28335 ADC采样程序,它使用了DSP库函数和中断来实现:
#include "F28335_adc.h"
#include "F28335_Gpio.h"
// 定义ADC采样数组
Uint16 AdcBuf[16];
// ADC中断服务程序
interrupt void AdcIsr(void)
{
// 清除ADC中断标志
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
// 读取ADC采样结果
AdcBuf[0] = AdcResult.ADCRESULT0;
AdcBuf[1] = AdcResult.ADCRESULT1;
AdcBuf[2] = AdcResult.ADCRESULT2;
AdcBuf[3] = AdcResult.ADCRESULT3;
AdcBuf[4] = AdcResult.ADCRESULT4;
AdcBuf[5] = AdcResult.ADCRESULT5;
AdcBuf[6] = AdcResult.ADCRESULT6;
AdcBuf[7] = AdcResult.ADCRESULT7;
AdcBuf[8] = AdcResult.ADCRESULT8;
AdcBuf[9] = AdcResult.ADCRESULT9;
AdcBuf[10] = AdcResult.ADCRESULT10;
AdcBuf[11] = AdcResult.ADCRESULT11;
AdcBuf[12] = AdcResult.ADCRESULT12;
AdcBuf[13] = AdcResult.ADCRESULT13;
AdcBuf[14] = AdcResult.ADCRESULT14;
AdcBuf[15] = AdcResult.ADCRESULT15;
}
void main(void)
{
// 初始化GPIO
InitGpio();
// 配置ADC
InitAdc();
// 配置ADC采样中断
EALLOW;
PieVectTable.ADCINT1 = &AdcIsr;
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
IER |= M_INT1;
EINT;
// 开始ADC采样
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;
while(1)
{
// 在这里可以对ADC采样结果进行处理
}
}
阅读全文