1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我想尝试使用ADC的四通道同时采样。我调整了所有的寄存器。采样后,微控制器需要SOC触发信号4次,转换为4香奈儿。但是我认为它应该把所有的信道转换成一个SoC触发信号。我尝试不同的SOC触发SUROCE甚至曼努埃尔采样和自动转换使用SAMP位。我的代码在下面。当调试此代码时,我不接受任何ADC中断,并且当我跟随寄存器时,我看到只有ADC1BUF0改变。有人帮忙吗?(包括:p24HXXX.H)α},包含:lt;xc.h & gt;如果定义的话(α-dSPIC33),包括“P33 FXXX.H”αELIF定义定时器1中断服务TraceNoReNo.AdviType(/(AythIdExtType,AyAutoSpvs*)).ADC1中断(空隙);int ADCValue1;int ADCValue2;int ADCValue3;int ADCValeE4;int主()/{//设置数字I/O,模拟INPUT,PWM,UART和中断SETUP();BrbBIT。RB9=1;PbBBIT。RB9=1;PoBBIT。RB9=1;PrBBIT。RB9= 1;PoBBIT。RB9=1;PoBBIT。RB9= 0;PoBbTys.RB9= 0;PoBbTys.RB9= 0;PoBbTys.RB9=Y;PoBBIT。RB9=0;BrbBIT。RB9=0;BrbBIT。RB9=0;PbBBIT。RB9=0;//等待AD1CON1比特上的ADC。SAMP=1;//开始采样/ /MUMUM 2*TAD D asasyvy易失性(“NOP”);// 25 NSαASMY易失性(“NOP”);// 25 ns ns AsMyv易失性(“NOP”);// 25 NSαASMY挥发(“NOP”);// 25 ns S./ / 25 NSαASMY挥发(“NOP”);/ / 25 NSαASMY挥发(“NOP”);/ / 25 NSαasm挥发(“NOP”);/ / 25 NSαASM挥发(“NOP”);/ / 25 NSαASM挥发(“NOP”);/ / 25 NSαASM挥发(“NOP”);/ / 25 NSαASM挥发(n)α-易失性(“NOP”)// 25 ns完全等待3×TADD AD1CON1比特;//开始连续转换{ 1 / /重复{{9}=1;POTBBITS。RB9=1;PrBBIT。RB9=1;PoBbTys.RB9=1;PoBbTys.RB9=1;PoBbTys.RB9=1;PoBbTys.RB9= 1;PoBbTys.RB9= 1;PoBbTys.BrbTys.RB9=9==0;PbBBIT。RB9=0;PbBBIT。RB9=0;PoBBIT。RB9=0;PoBBIT。RB9=0;PbBBIT。RB9=0;}无效设置();{//OFSC=80MHz CKDVIDES.PLLPREP= 0B0000;//N1=2叶B=0x1dE;/m=32 Ile AAR-CLKD。波比特TLISBIT=0x00;/TnbBi.TrISB7=1;TrISBBIT。TrISB0=1;TrISBBIT。TrISB1=1;TrISABIIT.tiSISA0=1;TrISABIIT.TISISA1=1;//配置AN0 AN3作为模拟输入AD1CON1BITS。ADON=0;//转ADC为AD1CONBITE位。AD12B=0;/ADC 10位AD1CON1BIT。S.表单=0;//整数数据格式AD1CON2BIT。VCFG2=1;/参考电压为VDD AD1CHS0BIT;/CH0负PIN为-VREF AD1CHS0BIT。CH0SA=0B000 011;//CH0连接AN3AD1CHS0BIT。CH0NB=0;/CH0负引脚为-VREF AD1CHS0BIT。CH0SB=0B000 011;//CH0连接AN3AD1CHS123比特。CH123SA=0;/CH1 AN0,CH2 AN1,CH3 AN2连接AD1CHS123位,CH123Na=0B00;/CH1,2,3负PIN为-VREF AD1CHS123位;CH1/ANS0,CH2 AN1,CH3 AN2连接AD1CHS123位。CH123Nb= 0B00;/CH1,2,3负PIN为-VREF AD1PCFGLITS。PCFG0=0;/AN0模拟AD1PCFGLITS。PCFG1=0;/AN1模拟AD1P。/CCFGLITS。PCFG2=0;/AN2模拟AD1PCFLBITS。PCFG3=0;/AN3模拟AD1CSLAMS.CSS0=0;//扫描有源ADS1SLCS.CSS1=0;//扫描有源AD1CSLBS.CSS2=0;//扫描有源AD1CSLDS.CSS3=0;//扫描有源AD1CON2BIT。CSCNA=0;AD1CON2BIT。BUFFM=0;ADPCON2BIT。CHPS=0B11;//转换CH0,1,2,3,AD1CON2位。SMPI=0B000;/1个中断,AD1CON2BIT。ALTs=1;Ad1CON1BIT。SIMSAM=1;/同时采样AD1CONBITS。ASAM=0;//手动采样AD1CONBITE。SSRC= 0B000;//清除采样比特端采样并开始转换AD1CON3BIT。ADRC=0;//采样时间=3TAD(MUMUM 2TAD)Ad1CON3000;/TAD=Test*(ADCs + 1)=25N*(2±1)=3×Tyn=75纳秒(MimuMUM 6NS)//ADC中断IFS0BIT。TSAMC=0B000 011;/*插入ISR代码在这里*/iEC0St.Ad1IE=0;ADCValue1= ADC1BUF0;;/YES,然后得到ADC值ADCValue2= ADC1BUF1;/Yes,然后得到ADC值ADCValue3= ADC1BUF2;/Yes,然后得到ADC值ADCValue4= ADC1BUF3;//是,然后获得ADC值,如果(ADCValue1和Gt;512)PoBBITS。RB12=1;否则PoBBITS. RB12=0;如果(ADCValue2和Gt;512)PtBBIT。RB13=1;否则(ADCValue3和Gt;512)PoBBITS。RB14=1;否则,BBBIT。RB14=0;IF(ADCValue4和Gt;512)PoBBITS。RB15=1;否则BurbButs.RB15=0;/*清除ADC中断*/IFS0BIT。AD1IF=0;IEC0= 1;};
以上来自于百度翻译 以下为原文 I want to try using four channel Simultaneous Sampling of ADC. I adjusted all of the register. But after sampling, microcontroler need SOC trigger signal 4 times to convert 4 chanel. But i think it should convert all of the channel with one SOC trigger signal. I try diffirent SOC trigger soruce even manuel sampling and automatic convert using SAMP bit. My code is below. When debug this code i dont take any ADC interrupt and when i follow the register, i see that only ADC1BUF0 changes. Is there anybody to help? #if defined(__dsPIC33F__) #include "p33fxxxx.h" #elif defined(__PIC24H__) #include "p24hxxxx.h" #endif #include #include //#include //#include "p30fxxxx.h" // Configuration settings //_FOSC(CSW_FSCM_OFF & FRC_PLL16); // Fosc=16x7.5MHz, Fcy=30MHz //_FWDT(WDT_OFF); // Watchdog timer off // Function prototypes void setup(); // Function prototype for Timer 1 interrupt service routine void __attribute__((__interrupt__, __auto_psv__)) _ADC1Interrupt(void); int ADCValue1; int ADCValue2; int ADCValue3; int ADCValue4; int main() { // Set up digital i/o, analog input, PWM, UART and interrupt setup(); PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; // wait for ADC on AD1CON1bits.SAMP =1; // Start sampling // Minumum 2*TAD __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns __asm__ volatile ("nop"); //25 ns Totally wait for 3*TAD AD1CON1bits.SAMP = 0; // Start the conversion while (1) // repeat continuously { PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=1; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; PORTBbits.RB9=0; } return 0; } void setup() { //FOSC=80MHz CLKDIVbits.PLLPRE=0b00000; //N1=2 ye böl PLLFBDbits.PLLDIV=0x1E; //M=32 ile çarp CLKDIVbits.PLLPOST=0b00; //N2=2 ye böl // Configure all port TRISB = 0x00; TRISBbits.TRISB7=1; TRISBbits.TRISB0=1; TRISBbits.TRISB1=1; TRISAbits.TRISA0 = 1; TRISAbits.TRISA1 = 1; // Configure AN0-AN3 as analog inputs AD1CON1bits.ADON = 0; //Turn ADC OFF AD1CON1bits.AD12B=0; //ADC 10 bit AD1CON1bits.FORM=0; //Integer data format AD1CON2bits.VCFG2=1; //Reference voltage is Vdd AD1CHS0bits.CH0NA=0; //CH0 negative pin is -Vref AD1CHS0bits.CH0SA=0b00011; //CH0 connected AN3 AD1CHS0bits.CH0NB=0; //CH0 negative pin is -Vref AD1CHS0bits.CH0SB=0b00011; //CH0 connected AN3 AD1CHS123bits.CH123SA=0; //CH1 AN0, CH2 AN1, CH3 AN2 connected AD1CHS123bits.CH123NA=0b00; //ch1,2,3 negative pin is -Vref AD1CHS123bits.CH123SB=0; //CH1 AN0, CH2 AN1, CH3 AN2 connected AD1CHS123bits.CH123NB=0b00; //ch1,2,3 negative pin is -Vref AD1PCFGLbits.PCFG0=0; //AN0 analog AD1PCFGLbits.PCFG1=0; //AN1 analog AD1PCFGLbits.PCFG2=0; //AN2 analog AD1PCFGLbits.PCFG3=0; //AN3 analog AD1CSSLbits.CSS0=0; // scaning active AD1CSSLbits.CSS1=0; // scaning active AD1CSSLbits.CSS2=0; // scaning active AD1CSSLbits.CSS3=0; // scaning active AD1CON2bits.CSCNA=0; AD1CON2bits.BUFM=0; AD1CON2bits.CHPS=0b11; //Converts Ch0,1,2,3 AD1CON2bits.SMPI=0b0000; //One interrupt per converstion AD1CON2bits.ALTS=1; AD1CON1bits.SIMSAM=1; //Simultaneous Sampling AD1CON1bits.ASAM=0; //Manual sampling AD1CON1bits.SSRC=0b000; //Clearing sample bit ends sampling and starts conversion AD1CON3bits.ADRC=0; //Use system clock AD1CON3bits.SAMC=0b00011; //Sample time = 3Tad (minumum 2Tad)) AD1CON3bits.ADCS=0b000001; //TAD=Tcy*(ADCS+1)=25ns*(2+1)=3*Tcy=75ns (minumum 65ns) // ADC Interrupt IFS0bits.AD1IF=0; IEC0bits.AD1IE=1; AD1CON1bits.ADON = 1; //Turn ADC ON } void __attribute__((__interrupt__,no_auto_psv)) _ADC1Interrupt(void) { /* Insert ISR Code Here*/ IEC0bits.AD1IE=0; ADCValue1 = ADC1BUF0; // yes then get ADC value ADCValue2 = ADC1BUF1; // yes then get ADC value ADCValue3 = ADC1BUF2; // yes then get ADC value ADCValue4 = ADC1BUF3; // yes then get ADC value if (ADCValue1> 512) PORTBbits.RB12=1; else PORTBbits.RB12=0; if (ADCValue2> 512) PORTBbits.RB13=1; else PORTBbits.RB13=0; if (ADCValue3> 512) PORTBbits.RB14=1; else PORTBbits.RB14=0; if (ADCValue4> 512) PORTBbits.RB15=1; else PORTBbits.RB15=0; /* Clear ADC interrupt */ IFS0bits.AD1IF=0; IEC0bits.AD1IE=1; } |
|
相关推荐
4个回答
|
|
我的土耳其语(?)也许你遇到了一些模棱两可的问题:同时采样不是同时转换!只有采样是同时的。你仍然需要多路复用ADC输入来转换存储的样本——一次一个。无论你做轮询(切换MUX,开始转换,等待转换完成,切换MUX等),还是通过中断(最终使用转换时间到良好的目的)是对你的。但不:这只是采样。
以上来自于百度翻译 以下为原文 My Turkish (?) is non-existent. Maybe you ran into some ambiguition: simultaneous SAMPLING is not simultaneous CONVERSION ! Only the sampling is simultaneous. You still have to multiplex the ADC inputs to convert the stored samples - one at a time. Whether you do that polling (switch the MUX, start the conversion, wait for the conversion to complete, switch the MUX etc.) or via interrupt (eventually using the conversion time to good purpose) is to you. But NO: it's only about SAMPLING. |
|
|
|
谢谢你的回答。但我知道,同时采样是从参考图片下面的图片同时转换的。
以上来自于百度翻译 以下为原文 du000001 thanks for your answer. But i understood that simultaneous sampling is simultaneous conversition from below picture taken from reference guide. https://yadi.sk/i/MXfuOYcC3J59Ji |
|
|
|
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5243 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3208 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2258 浏览 5 评论
779浏览 1评论
672浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
598浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
682浏览 0评论
579浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 22:00 , Processed in 1.488617 second(s), Total 84, Slave 68 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号