完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
买得研旭的板子,跟着手把手教学那本书在学,现在学到了ADC模块,根据研旭给的例程,对其中ADC模块产生中断的原理不懂,具体如下:(红色为我标记不懂的地方,其他颜色为例程程序)
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File #include "DSP2833x_Examples.h" // DSP2833x Examples Include File // Determine when the shift to right justify the data takes place // Only one of these should be defined as 1. // The other two should be defined as 0. #define POST_SHIFT 0 // Shift results after the entire sample table is full #define INLINE_SHIFT 1 // Shift results as the data is taken from the results regsiter #define NO_SHIFT 0 // Do not shift the results // ADC start parameters #if (CPU_FRQ_150MHZ) // Default - 150 MHz SYSCLKOUT #define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz #endif #if (CPU_FRQ_100MHZ) #define ADC_MODCLK 0x2 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 100/(2*2) = 25.0 MHz #endif #define ADC_CKPS 0x0 // ADC module clock = HSPCLK/1 = 25.5MHz/(1) = 25.0 MHz #define ADC_SHCLK 0x1 // S/H width in ADC module periods = 2 ADC cycle #define AVG 1000 // Average sample limit #define ZOFFSET 0x00 // Average Zero offset #define BUF_SIZE 512 // Sample buffer size // Global variable for this example Uint16 SampleTable[BUF_SIZE]; main() { Uint16 i; Uint16 array_index=0; InitSysCtrl(); EALLOW; SysCtrlRegs.HISPCP.all = ADC_MODCLK; // HSPCLK = SYSCLKOUT/ADC_MODCLK EDIS; DINT; InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; InitPieVectTable(); InitAdc(); // For this example, init the ADC // Specific ADC setup for this example: AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK; // Sequential mode: Sample rate = 1/[(2+ACQ_PS)*ADC clock in ns] // = 1/(3*40ns) =8.3MHz (for 150 MHz SYSCLKOUT) // = 1/(3*80ns) =4.17MHz (for 100 MHz SYSCLKOUT) // If Simultaneous mode enabled: Sample rate = 1/[(3+ACQ_PS)*ADC clock in ns] AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS; AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; // 1 Cascaded mode AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x1; AdcRegs.ADCTRL1.bit.CONT_RUN = 1; // Setup continuous run AdcRegs.ADCTRL1.bit.SEQ_OVRD = 1; // Enable Sequencer override feature AdcRegs.ADCCHSELSEQ1.all = 0x0; // Initialize all ADC channel selects to A0 AdcRegs.ADCCHSELSEQ2.all = 0x0; AdcRegs.ADCCHSELSEQ3.all = 0x0; AdcRegs.ADCCHSELSEQ4.all = 0x0; AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 0x1; // convert and store in 8 results registers // Clear SampleTable for (i=0; i SampleTable = 0; } // Start SEQ1 AdcRegs.ADCTRL2.all = 0x2000;这么写值,并没有使能SEQ1或SEQ2的中断,难道是例程错了吗? while(1) { // array_index = 0; while(AdcRegs.ADCST.bit.INT_SEQ1 == 0);上面没有开中断,那么这里查询中断标志就没意义啊。 // GpioDataRegs.GPBSET.bit.GPIO34 = 1; // Set GPIO34 for monitoring -optional AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; SampleTable[array_index++]= ( (AdcRegs.ADCRESULT0)>>4); if(array_index>(BUF_SIZE-1)) array_index=0; DELAY_US(100); GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1; // Clear GPIO34 for monitoring -optional } } //=========================================================================== // No more. //=========================================================================== 感谢各位解答!! |
|
相关推荐
3个回答
|
|
中断使能是指CPU可以响应中断;如果禁止使能,当中断标志位置1时,CPU无响应;标志位与是否使能无联系。不知回答的对不对,,,
|
|
|
|
AdcRegs.ADCTRL2.all = 0x2000;有INT_MOD_SEQ1中断模式选择位:在每次SEQ1序列结束产生中断事件,即INT_SEQ1置1.
|
|
|
|
用户名WTF 发表于 2016-3-2 19:08 我也只能看到这里,希望互相交流。 |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
基于 DSP5509 进行数字图像处理中 Sobel 算子边缘检测的硬件连接电路图
3296 浏览 0 评论
801 浏览 0 评论
普中科技F28335开发板中,如何使用aic23播放由代码生成的正弦波
3730 浏览 0 评论
4484 浏览 1 评论
1396 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 11:14 , Processed in 0.466491 second(s), Total 45, Slave 39 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号