打印
[DSP编程]

看不懂这程序的作用!!求指点下

[复制链接]
775|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
荼蘼的夏伤|  楼主 | 2016-5-4 20:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
interrupt void adc_isr(void);

// Global variables used in this example:
Uint16 LoopCount;
Uint16 ConversionCount;
Uint16 Frequence;//5,10,15,20,25,30,35,40,45,50Hz:
Uint16 Voltage;  //30,49,66,88,110,154,176,180,220v:

void DSP281x_ADCIO(void)
{
   InitAdc();  // For this example, init the ADC
// Enable ADCINT in PIE
   PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
   IER |= M_INT1; // Enable CPU Interrupt 1
   EINT;          // Enable Global interrupt INTM
   ERTM;          // Enable Global realtime interrupt DBGM

   LoopCount = 0;
   ConversionCount = 0;
   
// Configure ADC:start/stop mode
   AdcRegs.ADCMAXCONV.all = 0x0000;       // Setup 2 conv's on SEQ1
   AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x3; // Setup ADCINA3 as 1st SEQ1 conv.
  
   AdcRegs.ADCTRL2.bit.EXT_SOC_SEQ1 = 1;  // Enable EXTSOC to start SEQ1
   AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;  // Enable SEQ1 interrupt (every EOS)
// Wait for ADC interrupt
   while(1)
   {
      LoopCount++;
   }
  
}
interrupt void  adc_isr(void)  // interrupt :Keyword
{  
  Frequence =(Uint16)((AdcRegs.ADCRESULT0 >>6)/81.6);//Input the Frequence
  Voltage =(Uint16)(4.4*Frequence);//Acorrding with VVVF curve get the voltage

  // If 40 conversions have been logged, start over
  if(ConversionCount == 1)
  {
     ConversionCount = 0;
  }
  else ConversionCount++;

  // Reinitialize for next ADC sequence
  AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;         // Reset SEQ1
  AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;       // Clear INT SEQ1 bit
  PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;   // Acknowledge interrupt to PIE  
  return;
}

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

6

帖子

0

粉丝