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.
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;
}
Hi,
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.
Can you please step through your code to find exactly when the fault occurs?
Thanks,
Ben Collier
I have checked by using break point during debugging, It jumps to illegal ISR as soon as ConfigurationAdc() function is called. is it due to the issue with the hardware? I have tried but i can not find the exact reason why it jumps to illegal ISR loop.
Hi,
Did you try stepping into that function to see if there is a specific line that is causing the illegal ISR?
Thanks,
Ben Collier
Hello,
Actually as soon as the function is called the debugger jumps to illegal ISR. so i can not stepping into the function to check which line of the function causes the issue. can you please check the same if possible?
I have also tried the example code available from controsuite adc_soc_epwm it aslo faces the same issue.
Thanks,
Krunal Shah
Hi,
I have also tried the example code available from controsuite adc_soc_epwm it aslo faces the same issue.
Could you try an example from C2000WARE or C2000 Academy?
Thanks,
Ben Collier
Hi,
Yes, I have tried the example from C2000WARE as well but faces the same issue. can you please look in to that, why the issue persist even with the example codes?
Hi,
I am out of office until 9/19/24, I will try to get back to you as soon as possible upon my return.
Thank you,
Ben Collier
Hi,
So any code that you load to the device causes an illegal ISR?
Do you have another board that you could try? Could you also try lowering the SYSCLK speed by adjusting PLL settings?
Thanks,
Ben Collier
I have tried PWM code like sine PWM and Space vector PWM and that are working fine.
I have also tried same code with the other board, but the issue still persists. The problem of illegal ISR comes as soon as ADC arrives in the code.
I will check by lowering SYSCLK speed. and get back to you soon.
Also, can you try using the driverlib examples located in [C2000WARE]/driverlib/[device]/examples/ ?
I'm not sure if you were using driverlib or bitfield examples, since above it looks like you were using bitfield.
Thanks,
Ben Collier