Tool/software: Code Composer Studio
Hello everyone,
I use a C2000 Piccolo LaunchPad evaluation board, equipped with the TMS320F28027 and I'm trying to implement a CPU Timer 1 Interrupt, every 1 sec, in order to automatically change the Comparator 2 internal reference set-point (Comp2Regs.RAMPMAXREF_SHWD), according to an exponential equation. In my code, I also use an ADC interrupt, for ADC conversion purposes. I thought that these 2 interrupts are independent. Although, it seems that the 2 interrupt functions do not operate properly. When I comment the line "IER = M_INT13", only the ADC Interrupt operates, whereas by commenting "IER = M_INT1", only the CPU Timer 1 interrupt operates. I attach you my main function, along with the 2 Interrupt function codes. For the Timer 1 interrupt, I used the "Example_2802xCpuTimer" as a guide. Please provide some help!
Thanks a lot, in advance!
Nick
#include "DSP28x_Project.h"
#include "stdio.h"
#include "math.h"
__interrupt void cpu_timer1_isr(void);
interrupt void adc1_isr(void);
//...
void main()
{
#ifdef _FLASH
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
#endif
InitSysCtrl();
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 0;
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.TINT1 = &cpu_timer1_isr;
EDIS;
InitCpuTimers();
ConfigCpuTimer(&CpuTimer1, 60, 1000000);
CpuTimer1Regs.TCR.all = 0x4001;
IER |= M_INT13;
EALLOW;
PieVectTable.ADCINT1 = &adc1_isr;
EDIS;
InitGPIO();
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
EDIS;
ADCConfig();
InitADC();
InitAIO();
InitEPwm3Example();
Comp();
CompTripZone();
scia_init();
scia_fifo_init();
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
EDIS;
IER |=M_INT3;
IER |= M_INT1;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
EINT;
ERTM;
for(;;);
}
//...
interrupt void adc1_isr(void)
{
if (button==1){
EALLOW;
EPwm1Regs.TZCTL.bit.DCAEVT2=3;
EPwm1Regs.CMPA.half.CMPA = 0;
DELAY_US(ADC_usDELAY);
EPwm4Regs.CMPA.half.CMPA = 1500;
EDIS;
}
temp=(3.3*AdcResult.ADCRESULT0)/4096;
flag1=AdcResult.ADCRESULT0/16;
flag2=AdcResult.ADCRESULT4/16;
scia_xmit(flag1);
sum=AdcResult.ADCRESULT0;
sum=sum/1000;
AV=AV+sum;
if (pointer<1000)
{ pointer=pointer+1;
}
else
{
RealVoltage=AV;
AV=0;
pointer =0;
}
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE
return;
}
//...
__interrupt void cpu_timer1_isr(void)
{
CpuTimer1.InterruptCount++;
flag3=CpuTimer1.InterruptCount;
if (CpuTimer1.InterruptCount<=120){
temp1 = 58000;
}
else if ((CpuTimer1.InterruptCount>120) && (CpuTimer1.InterruptCount<=300)){
temp1 = 58000*exp((-flag3+120)/(100+6*flag3));
}
else{
temp1 = 52800;
}
Comp2Regs.RAMPMAXREF_SHDW=temp1;
}