使用TMS320F28XX的ADC采样,ADC采样使能INT SEQ1中断,使用ePWMVxSOCA触发信号启动SEQ1,配置如下:
// Configure ADC
AdcRegs.ADCMAXCONV.all = 0x0001; // Setup 2 conv's on SEQ1
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x3; // Setup ADCINA3 as 1st SEQ1 conv.
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x2; // Setup ADCINA2 as 2nd SEQ1 conv.
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;// Enable SOCA from ePWM to start SEQ1
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; // Enable SEQ1 interrupt (every EOS)
// Assumes ePWM1 clock is already enabled in InitSysCtrl();
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
请问初始化完后,时基计数器(TBCTR)是从0开始计数么?当计数到CMPA时,进入ADC中断。当中断执行后,时基计数器(TBCTR)是继续递增到TBPRD后从0开始 还是直接置0?不知道时基计数器(TBCTR)是怎么工作的?请指教,谢谢。
囧:
计数到TBPRD后再清零,TBCTR只会在计数到TBPRD后才会清零,跟ADCSOC和其他事件无关
使用TMS320F28XX的ADC采样,ADC采样使能INT SEQ1中断,使用ePWMVxSOCA触发信号启动SEQ1,配置如下:
// Configure ADC
AdcRegs.ADCMAXCONV.all = 0x0001; // Setup 2 conv's on SEQ1
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x3; // Setup ADCINA3 as 1st SEQ1 conv.
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x2; // Setup ADCINA2 as 2nd SEQ1 conv.
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;// Enable SOCA from ePWM to start SEQ1
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; // Enable SEQ1 interrupt (every EOS)
// Assumes ePWM1 clock is already enabled in InitSysCtrl();
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
请问初始化完后,时基计数器(TBCTR)是从0开始计数么?当计数到CMPA时,进入ADC中断。当中断执行后,时基计数器(TBCTR)是继续递增到TBPRD后从0开始 还是直接置0?不知道时基计数器(TBCTR)是怎么工作的?请指教,谢谢。
liangliang luan:
回复 囧:
假如计数到TBPRD后再清零,然后再计数到CMPA时,ADC中断还没有执行完怎么办呢?
使用TMS320F28XX的ADC采样,ADC采样使能INT SEQ1中断,使用ePWMVxSOCA触发信号启动SEQ1,配置如下:
// Configure ADC
AdcRegs.ADCMAXCONV.all = 0x0001; // Setup 2 conv's on SEQ1
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x3; // Setup ADCINA3 as 1st SEQ1 conv.
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x2; // Setup ADCINA2 as 2nd SEQ1 conv.
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;// Enable SOCA from ePWM to start SEQ1
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; // Enable SEQ1 interrupt (every EOS)
// Assumes ePWM1 clock is already enabled in InitSysCtrl();
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
请问初始化完后,时基计数器(TBCTR)是从0开始计数么?当计数到CMPA时,进入ADC中断。当中断执行后,时基计数器(TBCTR)是继续递增到TBPRD后从0开始 还是直接置0?不知道时基计数器(TBCTR)是怎么工作的?请指教,谢谢。
囧:
回复 liangliang luan:
会继续执行前一次的中断,知道执行完,如果是这样的情况,就说明目前CPU的负载率太高,已经超过100%,应该精简你的中断服务程序,或者把中断改成三次或者六次事件触发一次
使用TMS320F28XX的ADC采样,ADC采样使能INT SEQ1中断,使用ePWMVxSOCA触发信号启动SEQ1,配置如下:
// Configure ADC
AdcRegs.ADCMAXCONV.all = 0x0001; // Setup 2 conv's on SEQ1
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x3; // Setup ADCINA3 as 1st SEQ1 conv.
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x2; // Setup ADCINA2 as 2nd SEQ1 conv.
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;// Enable SOCA from ePWM to start SEQ1
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; // Enable SEQ1 interrupt (every EOS)
// Assumes ePWM1 clock is already enabled in InitSysCtrl();
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
请问初始化完后,时基计数器(TBCTR)是从0开始计数么?当计数到CMPA时,进入ADC中断。当中断执行后,时基计数器(TBCTR)是继续递增到TBPRD后从0开始 还是直接置0?不知道时基计数器(TBCTR)是怎么工作的?请指教,谢谢。
liangliang luan:
回复 囧:
假如我想定时采样的话,那么采样的第一个数得去掉,同时采样间隔不能太短,否则下一个采样到来有可能ADC中断还没执行完?感觉这样设计是不是不科学啊
使用TMS320F28XX的ADC采样,ADC采样使能INT SEQ1中断,使用ePWMVxSOCA触发信号启动SEQ1,配置如下:
// Configure ADC
AdcRegs.ADCMAXCONV.all = 0x0001; // Setup 2 conv's on SEQ1
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x3; // Setup ADCINA3 as 1st SEQ1 conv.
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x2; // Setup ADCINA2 as 2nd SEQ1 conv.
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;// Enable SOCA from ePWM to start SEQ1
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; // Enable SEQ1 interrupt (every EOS)
// Assumes ePWM1 clock is already enabled in InitSysCtrl();
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
请问初始化完后,时基计数器(TBCTR)是从0开始计数么?当计数到CMPA时,进入ADC中断。当中断执行后,时基计数器(TBCTR)是继续递增到TBPRD后从0开始 还是直接置0?不知道时基计数器(TBCTR)是怎么工作的?请指教,谢谢。
囧:
回复 liangliang luan:
第一个采样扔掉的话,你可以设置SOC0为第一个采样,SOC1和SOC0对应同一个ADC通道。设置SOC1触发ADC中断就可以。
ADC中断应该是本次中断需要的所有采样结果完成才触发。中断时间你可以在服务程序的头尾加入GPIO翻转来看负载率,建议不要超过百分之60
使用TMS320F28XX的ADC采样,ADC采样使能INT SEQ1中断,使用ePWMVxSOCA触发信号启动SEQ1,配置如下:
// Configure ADC
AdcRegs.ADCMAXCONV.all = 0x0001; // Setup 2 conv's on SEQ1
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x3; // Setup ADCINA3 as 1st SEQ1 conv.
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x2; // Setup ADCINA2 as 2nd SEQ1 conv.
AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;// Enable SOCA from ePWM to start SEQ1
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; // Enable SEQ1 interrupt (every EOS)
// Assumes ePWM1 clock is already enabled in InitSysCtrl();
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
请问初始化完后,时基计数器(TBCTR)是从0开始计数么?当计数到CMPA时,进入ADC中断。当中断执行后,时基计数器(TBCTR)是继续递增到TBPRD后从0开始 还是直接置0?不知道时基计数器(TBCTR)是怎么工作的?请指教,谢谢。
liangliang luan:
回复 囧:
负载率是指(中断执行时间)/(ADC采样的中断间隔)么?