ADC最大采样数设置问题

2019-07-30 15:02发布

  AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 0x7;  // convert and store in 8 results registers
   AdcRegs.ADCMAXCONV.bit.MAX_CONV2 = 0x3;
本人新手,求高手解答为什么这样编写语句第二条语句会无效呢???
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
13条回答
824653578
2019-07-31 15:45
小木欧尼 发表于 2014-10-13 20:13
支持楼上的

这个可以有效,测试成功。
  谢谢回复,问题已解决。下面是程序设置

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 = 0x0;
//   AdcRegs.ADCTRL1.bit.CONT_RUN = 1;       // Setup continuous

//   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 = 0x3;  
   AdcRegs.ADCMAXCONV.bit.MAX_CONV2 = 0x3;

// Step 5. User specific code, enable interrupts:


// Clear SampleTable
   for (i=0; i<BUF_SIZE; i++)
   {
     SampleTable = 0;
   }

// Start SEQ1
   AdcRegs.ADCTRL2.all = 0x2000;//软件触发SOC
//         AdcRegs.ADCTRL2.all = 0x0020;
   for(;;)
   {  // Take ADC data and log them in SampleTable array

     // Initalize the array index.  This points to the current
     // location within the SampleTable
     array_index = 0;

     for (i=0; i<(BUF_SIZE/16); i++)
     {
       // Wait for int1
       while (AdcRegs.ADCST.bit.INT_SEQ1== 0){}
//       while (AdcRegs.ADCST.bit.INT_SEQ1== 1){}
       GpioDataRegs.GPBSET.bit.GPIO34 = 1;  // Set GPIO34 for monitoring  -optional

       AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;

                #if INLINE_SHIFT
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT0)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT1)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT2)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT3)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT4)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT5)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT6)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT7)>>4);
               
                #endif //-- INLINE_SHIFT

                #if NO_SHIFT || POST_SHIFT
               
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT0));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT1));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT2));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT3));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT4));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT5));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT6));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT7));

                #endif //-- NO_SHIFT || POST_SHIFT
                AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;


           AdcRegs.ADCTRL2.all = 0x0020;//软件触发


       while (AdcRegs.ADCST.bit.INT_SEQ2== 0){}
//             while (AdcRegs.ADCST.bit.INT_SEQ1== 1){}
           GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1;  // Clear GPIO34 for monitoring  -optional
       AdcRegs.ADCST.bit.INT_SEQ2_CLR = 1;

                #if INLINE_SHIFT
               
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT8)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT9)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT10)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT11)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT12)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT13)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT14)>>4);
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT15)>>4);
               
                #endif //-- INLINE_SHIFT
               
                #if NO_SHIFT || POST_SHIFT
               
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT8));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT9));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT10));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT11));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT12));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT13));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT14));
                       SampleTable[array_index++]= ( (AdcRegs.ADCRESULT15));
                #endif // -- NO_SHIFT || POST_SHIFT

                }
       
       
        #if POST_SHIFT
            // For post shifting, shift the ADC results
            // in the SampleTable buffer after the buffer is full.
            for (i=0; i<BUF_SIZE; i++)
            {
              SampleTable = ((SampleTable) >>4);
            }
        #endif // -- POST_SHIFT
          AdcRegs.ADCTRL2.bit.RST_SEQ2 = 1;  ////////////////////////////////////////////////////////////////////
            GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1;  // Clear GPIO34 for monitoring  -optional
  }

一周热门 更多>