【DSP】TMS320F28035 ADC例程(ePWM+中断)

#include "DSP28x_Project.h"

interrupt void adc_isr(void);

Uint16 ConversionCount;
Uint16 Voltage1[10];
Uint16 Voltage2[10];

main()
{
   InitSysCtrl();

   DINT;
   InitPieCtrl();
   IER = 0x0000;
   IFR = 0x0000;
   InitPieVectTable();

   EALLOW;
   PieVectTable.ADCINT1 = &adc_isr; //映射ADC中断
   EDIS;

   InitAdc();

   PieCtrlRegs.PIEIER1.bit.INTx1 = 1;   //使能PIE级INT1.1中断
   IER |= M_INT1;                       //使能CPU级INT1中断
   EINT;                                //使能总中断

   ConversionCount = 0;

    EALLOW;
    AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1;    //转换完成前一个ADC时钟周期产生EOC
    AdcRegs.INTSEL1N2.bit.INT1E     = 1;    //使能ADCINT1
    AdcRegs.INTSEL1N2.bit.INT1CONT  = 0;    //关闭连续模式
    AdcRegs.INTSEL1N2.bit.INT1SEL   = 1;    //将ADCINT1映射到EOC1
    AdcRegs.ADCSOC0CTL.bit.CHSEL    = 0;    //将ADCINA0映射到通道0
    AdcRegs.ADCSOC1CTL.bit.CHSEL    = 1;    //将ADCINA1映射到通道1
    AdcRegs.ADCSOC0CTL.bit.TRIGSEL  = 5;    //ePWM1A触发SOC0
    AdcRegs.ADCSOC1CTL.bit.TRIGSEL  = 5;    //ePWM1A触发SOC1
    AdcRegs.ADCSOC0CTL.bit.ACQPS    = 6;    //设置窗口采样次数
    AdcRegs.ADCSOC1CTL.bit.ACQPS    = 6;    //设置窗口采样次数
    EDIS;

    //还没开始研究ePWM
   EPwm1Regs.ETSEL.bit.SOCAEN   = 1;        // Enable SOC on A group
   EPwm1Regs.ETSEL.bit.SOCASEL  = 4;        // Select SOC from from CPMA on upcount
   EPwm1Regs.ETPS.bit.SOCAPRD   = 1;        // Generate pulse on 1st event
   EPwm1Regs.CMPA.half.CMPA     = 0x0080;   // Set compare A value
   EPwm1Regs.TBPRD              = 0xFFFF;   // Set period for ePWM1
   EPwm1Regs.TBCTL.bit.CTRMODE  = 0;        // count up and start

   for(;;)
   {
   }

}


interrupt void  adc_isr(void)
{

  Voltage1[ConversionCount] = AdcResult.ADCRESULT0;
  Voltage2[ConversionCount] = AdcResult.ADCRESULT1;

  if(ConversionCount == 9)
  {
     ConversionCount = 0;
  }
  else ConversionCount++;

  AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;     //清除EOC1信号(ADCINT1)
  PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;   //写1清0,写0无效
}
TMS320F28035是德州仪器(Texas Instruments)推出的一款数字信号控制器(Digital Signal Controller,DSC),它具有高性能的计算能力和丰富的外设接口。EPWM(Enhanced Pulse Width Modulation)是TMS320F28035中的一个模块,用于产生PWM信号。根据引用\[1\],在EPWM1模块中,ePWMA和ePWMB被设置为影子模式,并且在计数器为0时重载。这意味着在每个周期的计数器为0时,ePWMA和ePWMB的值会被重新加载。根据引用\[2\],如果要配置EPWM1的中断频率为300KHZ,则单个周期为3.333333333333333us,因此需要200个中断周期。根据引用\[3\],DCAH连接到比较器1的输出,DCAL连接到TZ2。其中,TZ2是一种功能,但在这个引用中没有具体使用到。 #### 引用[.reference_title] - *1* *3* [TMS320F28035学习笔记1_模拟比较器程序_Example_2803xEPwmDCEventTripComp](https://blog.csdn.net/weixin_44618926/article/details/120554126)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [TMS320F28035 的EPWM触发ADC采样笔记](https://blog.csdn.net/tiantangmoke/article/details/109056661)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值