This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28379D: Debugger automatically jumps to illegal ISR loop of defaultSR.C while debugging code for ADC test.

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software:

I am trying to check ADC working and for that purpose I have used ADCA2, and DACOUTA and I have used EPWM3 for SOC. I am taking one random number (1000) from DACOUTA and give it as a input to ADCINA2 by connecting PIN30 to PIN29 on TMS320F28309D launchpad. now as soon i press the run button into debug mode the debugger jumps to illegal ISR loop of F2837xD_DefaultISR.c file. Please guide to solve this issue.

#include "F28x_Project.h"

// Function prototypes
void Gpio_select(void);
void Setup_epwm(void);
void ConfigureAdc(void);
void SetupADCSoftware(void);
void Initdaca(void);
void InitdacB(void);
void ConfigureADCInterrupts(void);
interrupt void adca1_isr(void);

// Variables to store ADC results
Uint16 ADCaResult0;
Uint16 ADCaResult1;
Uint16 ADCbResult0;
Uint16 ADCbResult1;

void main(void)
{
// Initialize system control
InitSysCtrl();

// Disable interrupts
DINT;
IER = 0x0000;
IFR = 0x0000;

// Initialize PIE control registers to default state
InitPieCtrl();

// Initialize PIE vector table with pointers to default ISR
InitPieVectTable();

// Map ADC interrupt to ISR
EALLOW;
PieVectTable.ADCA1_INT = &adca1_isr;
EDIS;

// Initialize peripherals
Gpio_select();
Setup_epwm();
ConfigureAdc();
SetupADCSoftware();
Initdaca();
InitdacB();
ConfigureADCInterrupts();

// Enable PIE and CPU interrupts
IER |= M_INT1; // Enable CPU interrupt for group 1 (ADCINT)
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable PIE group 1 interrupt (ADC A)

// Enable global interrupts and real-time interrupts
EINT;
ERTM;

// Main loop
while(1)
{
// ADC results are updated in the ADC ISR
}
}

void Gpio_select(void)
{
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 1; // GPIO4 as EPWM3A
GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 1; // GPIO5 as EPWM3B
EDIS;
}

void Setup_epwm(void)
{
EPwm3Regs.TBCTL.bit.CLKDIV = 0;
EPwm3Regs.TBCTL.bit.HSPCLKDIV = 0;
EPwm3Regs.TBCTL.bit.CTRMODE = 2; // Up-down count mode
EPwm3Regs.TBPRD = 6944; // Set PWM period
EPwm3Regs.AQCTLA.all = 0x0090; // Set PWM actions
EPwm3Regs.CMPA.bit.CMPA = 6944 / 2; // Set compare value

EPwm3Regs.ETSEL.bit.SOCAEN = 1; // Enable SOCA (start of conversion for ADC)
EPwm3Regs.ETSEL.bit.SOCASEL = 1; // Trigger on TBCTR = 0
EPwm3Regs.ETPS.bit.SOCAPRD = 1; // Trigger on every event
EPwm3Regs.ETCLR.bit.SOCA = 1; // Clear any pending SOCA events
}

void Initdaca(void)
{
EALLOW;
DacaRegs.DACCTL.bit.DACREFSEL = 1; // Use internal VDAC as reference
DacaRegs.DACCTL.bit.LOADMODE = 0; // Load on next SYSCLK
DacaRegs.DACOUTEN.bit.DACOUTEN = 1; // Enable DAC output
DacaRegs.DACVALS.bit.DACVALS = 1000; // Set DAC output value
DELAY_US(10);
EDIS;
}

void InitdacB(void)
{
EALLOW;
DacbRegs.DACCTL.bit.DACREFSEL = 1;
DacbRegs.DACCTL.bit.LOADMODE = 0;
DacbRegs.DACOUTEN.bit.DACOUTEN = 1;
DacbRegs.DACVALS.bit.DACVALS = 1000;
DELAY_US(10);
EDIS;
}

void ConfigureAdc(void)
{
EALLOW;
CpuSysRegs.PCLKCR13.bit.ADC_A = 1; // Enable ADC_A clock
CpuSysRegs.PCLKCR13.bit.ADC_B = 1; // Enable ADC_B clock

AdcaRegs.ADCCTL2.bit.PRESCALE = 6; // Set ADC clock
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up ADC_A

AdcbRegs.ADCCTL2.bit.PRESCALE = 6;
AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up ADC_B
EDIS;

DELAY_US(1000); // Wait for ADC to stabilize
}

void SetupADCSoftware(void)
{
Uint16 acqps;

// Set acquisition window based on resolution
acqps = (ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION) ? 14 : 63;

EALLOW;
// Configure SOC0 and SOC1 for ADCA
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2; // Sample from channel 2
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps;
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 9; // Triggered by ePWM3 SOCA

AdcaRegs.ADCSOC1CTL.bit.CHSEL = 3; // Sample from channel 3
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps;
AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = 9;

// Configure SOC0 and SOC1 for ADCB
AdcbRegs.ADCSOC0CTL.bit.CHSEL = 2; // Sample from channel 2
AdcbRegs.ADCSOC0CTL.bit.ACQPS = acqps;
AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 9;

AdcbRegs.ADCSOC1CTL.bit.CHSEL = 3; // Sample from channel 3
AdcbRegs.ADCSOC1CTL.bit.ACQPS = acqps;
AdcbRegs.ADCSOC1CTL.bit.TRIGSEL = 9;
EDIS;
}

void ConfigureADCInterrupts(void)
{
EALLOW;

// Enable the ADC interrupt in the ADC module
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // Enable ADCINT1
AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 0; // Disable continuous mode
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // EOC0 triggers ADCINT1

PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable PIE group 1 interrupt for ADC A
IER |= M_INT1; // Enable CPU interrupt for group 1
EDIS;
}

// ADC A Interrupt Service Routine
interrupt void adca1_isr(void)
{
// Read ADC results from SOC0 and SOC1
ADCaResult0 = AdcaResultRegs.ADCRESULT0; // Read ADC result from ADCA0
ADCaResult1 = AdcaResultRegs.ADCRESULT1; // Read ADC result from ADCA1
ADCbResult0 = AdcbResultRegs.ADCRESULT0; // Read ADC result from ADCB0
ADCbResult1 = AdcbResultRegs.ADCRESULT1; // Read ADC result from ADCB1

// Clear ADC interrupt flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

// Acknowledge the PIE interrupt
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}