TMS320F280049C ADC学习总结 |
您所在的位置:网站首页 › adc的电路组成 › TMS320F280049C ADC学习总结 |
1、介绍 ADC模块是一个12位逐次逼近(SAR)式ADC。ADC由核心和包装器组成。核心部分由模拟电路组成,包括通道选择MUX、采样保持(S/H)电路、逐次逼近电路、基准电压电路和其它模拟支持电路。包装器由配置和控制ADC。这些电路包括可编程转换逻辑、结果寄存器、模拟电路接口、外围总线接口、后处理电路以及与其他片上模块的接口。每个ADC模块由一个采样保持(s/h)电路组成。ADC模块设计为在同一芯片上多次复制,允许多个ADC同时采样或独立操作。ADC包装器基于转换开始(SOC)。 2、特点 3、ADC Block Diagram 4、配置 ClockResolutionSignal modeReference voltage sourceTrigger sourceConverted channelAcquisition window durationEOC locationBurst Mode5、程序 //! This example converts some voltages on ADCA based on a software trigger. //! - \b adcAResult0 - Digital representation of the voltage on pin A0 #include "driverlib.h" #include "device.h" uint16_t adcAResult0; void initADCs(void); void initADCSOCs(void); void main(void) { Device_init(); //100 MHz Interrupt_initModule(); Interrupt_initVectorTable(); // 初始化ADC,初始化SOC为软件触发。 // Set up ADCs, initializing the SOCs to be triggered by software initADCs(); initADCSOCs(); EINT; ERTM; while(1) { // 软件触发ADC转换。 // Convert, wait for completion, and store results ADC_forceSOC(ADCA_BASE, ADC_SOC_NUMBER0); // 等待ADC转换完成,并清除中断标志位 while(ADC_getInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1) == false) { } ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1); // 储存结果 adcAResult0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0); // 用于调试的软件暂停。 // Software breakpoint. At this point, conversion results are stored in adcAResult0, ESTOP0; } }
// 初始化ADC void initADCs(void) { // ADC使用片内参考3.3V // Setup VREF as internal ADC_setVREF(ADCA_BASE, ADC_REFERENCE_INTERNAL, ADC_REFERENCE_3_3V); // ADC时钟4分频 // Set ADCCLK divider to /4 ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0); // 设置转换结束时触发中断 // Set pulse positions to late ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV); // 启动AD并延迟1ms // Power up the ADCs and then delay for 1 ms ADC_enableConverter(ADCA_BASE); DEVICE_DELAY_US(1000); }
// 初始化ADCSOC void initADCSOCs(void) { // 采样窗口持续10个系统时钟 // - SOC0 will convert pin A0 with a sample window of 10 SYSCLK cycles. ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN0, 10); // 设置中断为ADCINT1,并启用 // Set SOC1 to set the interrupt 1 flag. Enable the interrupt and make sure its flag is cleared. ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER1); ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1); ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1); } 6、总结 主要配置:SOCS(trigger source, channel to convert, and acquisition (sample) window duration): AdcaRegs.ADCSOC0CTL.bit.CHSEL = 1; AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9; AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 1;//SOC5 will convert ADCINA1 //SOC5 will use sample duration of 10 SYSCLK cycles //SOC5 will begin conversion on XX SOCB ADInit:ADC_setVREF(ADCA_BASE, ADC_REFERENCE_INTERNAL, ADC_REFERENCE_3_3V); //参考电压 ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0); // ADC时钟4分频 ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV); // 设置转换结束时触发中断 ADC_enableConverter(ADCA_BASE); // 启动AD并延迟1ms DEVICE_DELAY_US(1000); ADCTestADC_forceSOC(ADCA_BASE, ADC_SOC_NUMBER0); // 软件触发ADC转换 while(ADC_getInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1) == false) {} // 等待ADC转换完成,并清除中断标位 ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1); adcAResult0 = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0); // 储存结果 7、温馨提示 愿君倾耐心之阅手册,册中定有助君之奥秘 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |