完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
|
|
相关推荐
6 个讨论
|
|
guigui_7044 发表于 2018-9-5 15:13 我改了个工程,试了下断点,可以重复的进timer的中断和ADC的中断,但是采样出来的结果特别奇怪,您能帮忙看看程序吗? main() [ // Uint16 i; Uint16 array_index; 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(); // EALLOW; // PieVectTable.TINT0 = &TINT0_ISR; // PieVectTable.ADCINT = &adc_isr; // EDIS; InitCpuTimers(); ConfigCpuTimer(&CpuTimer0, 150, 100); StartCpuTimer0(); InitAdc(); // IER |= M_INT1; IER |= M_INT1; // Enable CPU Interrupt 1 PieCtrlRegs.PIECTRL.bit.ENPIE = 1; PieCtrlRegs.PIEIER1.bit.INTx7 = 1; PieCtrlRegs.PIEIER1.bit.INTx6 = 1; EINT; ERTM; // For this example, init the ADC // EALLOW; // 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; // 级联 AdcRegs.ADCTRL3.bit.SMODE_SEL = 1; //同步采样 AdcRegs.ADCTRL1.bit.CONT_RUN = 0; // 启停模式 AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 0x0; // 设置1对转换通道 AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0; //设置ADC A0/B0为第一个变换 AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; //使能SEQ1中断 // wait for adc interrupt for(;;) [ LoopCount++; ] ] interrupt void ADCINT_ISR(void) // ADC [ // SampleCount++; adc[0]= AdcRegs.ADCRESULT0 >>4; adc[1]= AdcRegs.ADCRESULT1 >>4; if (count<500) [ abc1[count]= adc[0]; abc2[count]= adc[1]; count ++; ] else [ count=0; ] EALLOW; AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // PieCtrlRegs.PIEACK.bit.ACK1=1; //响应PIE同组中断 AdcRegs.ADCST.bit.INT_SEQ1_CLR=1; //清除AD中断的标志位 // EINT; //使能全局中断 // Insert ISR Code here // To receive more interrupts from this PIE group, acknowledge this interrupt // PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Next two lines for debug only to halt the processor here // Remove after inserting ISR Code // asm (" ESTOP0"); // for(;;); PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; return; ] // INT1.7 interrupt void TINT0_ISR(void) // CPU-Timer 0 [ CpuTimer0.InterruptCount++; // Acknowledge this interrupt to receive more interrupts from group 1 //0x0001赋给12组中断ACKnowledge寄存器,对其全部清除,不接受其他中断 CpuTimer0Regs.TCR.bit.TIF=1; // 定时到了指定时间,标志位置位,清除标志 CpuTimer0Regs.TCR.bit.TRB=1; // 重载Timer0的定时数据 AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; return; // Insert ISR Code here // To receive more interrupts from this PIE group, acknowledge this interrupt // PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Next two lines for debug only to halt the processor here // Remove after inserting ISR Code // asm (" ESTOP0"); // for(;;); ] 主函数以及两个中断函数 |
|
|
|
|
|
|
|
|
能帮忙看看为什么这转化后不正常吗 void InitAdc(void) [ extern void DSP28x_usDelay(Uint32 Count); // *IMPORTANT* // The ADC_cal function, which copies the ADC calibration values from TI reserved // OTP into the ADCREFSEL and ADCOFFTRIM registers, occurs automatically in the // Boot ROM. If the boot ROM code is bypassed during the debug process, the // following function MUST be called for the ADC to function according // to specification. The clocks to the ADC MUST be enabled before calling this // function. // See the device data manual and/or the ADC Reference // Manual for more information. EALLOW; SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; // 使能ADC时钟 ADC_cal(); EDIS; // To powerup the ADC the ADCENCLK bit should be set first to enable // clocks, followed by powering up the bandgap, reference circuitry, and ADC core. // Before the first conversion is performed a 5ms delay must be observed // after power up to give all analog circuits time to power up and settle // Please note that for the delay function below to operate correctly the // CPU_RATE define statement in the DSP2833x_Examples.h file must // contain the correct CPU clock period in nanoseconds. AdcRegs.ADCTRL3.all = 0x00E0; // Power up bandgap/reference/ADC circuits DELAY_US(ADC_usDELAY); // Delay before converting ADC channels EALLOW; DSP28x_usDelay(50); AdcRegs.ADCTRL1.bit.RESET = 0; //0:无效,1:复位整个ADC模块 AdcRegs.ADCTRL1.bit.CPS = 0; //转换时间预标定器 0:f=CLK/1 1:f=CLK/2 AdcRegs.ADCTRL1.bit.ACQ_PS=4; //window ACQ_PS*Tclk(采样时间选择) AdcRegs.ADCTRL1.bit.CONT_RUN = 1; //0:非连续运行,1:连续运行 AdcRegs.ADCTRL3.bit.ADCCLKPS = 1; //ADC内核时钟分频器:ADCLK = HSPCLK--75M/[2xnx(CPS+1)] AdcRegs.ADCTRL1.bit.SEQ_CASC=1; //0:双排序器模式,1:级联排序器模式 AdcRegs.ADCTRL3.bit.SMODE_SEL=0; //0:顺序采样,1:同步采样 AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 0; //最大转换通道数 = MAXCONVn +1 /**********************输入通道选择排序*************************************/ AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0; //ADC_A0--Udc // AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 1; //ADC_A1--Idc // AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 2; //ADC_A2--Ic // AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 3; //ADC_A3--Ib // AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 4; //ADC_A4--Ia // AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 5; //ADC_A5--Uc // AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 6; //ADC_A6--Ub // AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 7; //ADC_A7--Ua // AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 8; // // AdcRegs.ADCCHSELSEQ3.bit.CONV09 = 9; // // AdcRegs.ADCCHSELSEQ3.bit.CONV10 = 10; // // AdcRegs.ADCCHSELSEQ3.bit.CONV11 = 11; // /**********************输入通道选择排序*************************************/ EDIS; AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; //复位排序器:0=无效;1=复位排序器到CONV00状态 AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1; //SEQ1的启动转换触发 AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1; //级联排序器使能ePWM_SOCA ] 然后是主函数, while(1) [ while(AdcRegs.ADCST.bit.INT_SEQ1==0); AdcRegs.ADCST.bit.INT_SEQ1_CLR=1; a=AdcRegs.ADCRESULT0>>4; b=a*1.0/4096*3; Oled_Print_5_6x8(2,2,b); ] ] |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
550 浏览 0 评论
1613 浏览 0 评论
2047 浏览 0 评论
为啥BQ7693003DBTR芯片在和BQ769X0盒子通讯时收不到信号?
1514 浏览 0 评论
DSP 28027F 开发板 XDS100v2调试探针诊断日志显示了 Error -150 (SC_ERR_FTDI_FAIL)如何解决
1338 浏览 0 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
1757浏览 29评论
2783浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
1724浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
1634浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
1645浏览 13评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 15:34 , Processed in 0.884639 second(s), Total 54, Slave 45 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1279