Hi,
Is there a way to check the status of the ADC/PWM interrupts, i.e. whether they are working or not?
I have placed some simple integer flags into my interrupts service routines, which are supposed to be triggered by an end of SOC on the ADC's. However, they are not triggering the ISR's at all.
The only ISR that I have which is working is one I trigger with Timer 0 interrupt.
There is no PWM being output on my board and thus there seems as though there is no triggering occuring. I have tried mapping the interrupts to the PWM, and to the ADC, and neither has worked.
It's almost as if my ADC's are not even sampling the signal, or if they are sampling the signal, they are not setting the interrupt flags once they have finished. Even if this is the case, I have tried using the interrupt flag associated with the PWM outputs I have selected, again to no avail.
I'm happy to insert some code but not entirely sure what will be the most relevant without pasting the entire project. Here is my ADC initialisation for now:
void InitADCs(void) // Write ADC configurations and power up all ADCs, ADCD not used
{
EALLOW; // Allow write to register
// ADC-A
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; // Set ADCCLK divider to /4
AdcaRegs.ADCCTL2.bit.RESOLUTION = 0; // 12-bit resolution
AdcaRegs.ADCCTL2.bit.SIGNALMODE = 0; // Single-ended channel conversions (12-bit mode only)
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1; // Set pulse positions to late
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up the ADC
// ADC-B
AdcbRegs.ADCCTL2.bit.PRESCALE = 6; // Set ADCCLK divider to /4
AdcbRegs.ADCCTL2.bit.RESOLUTION = 0; // 12-bit resolution
AdcbRegs.ADCCTL2.bit.SIGNALMODE = 0; // Single-ended channel conversions (12-bit mode only)
AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1; // Set pulse positions to late
AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up the ADC
// ADC-C
AdccRegs.ADCCTL2.bit.PRESCALE = 6; // Set ADCCLK divider to /4
AdccRegs.ADCCTL2.bit.RESOLUTION = 0; // 12-bit resolution
AdccRegs.ADCCTL2.bit.SIGNALMODE = 0; // Single-ended channel conversions (12-bit mode only)
AdccRegs.ADCCTL1.bit.INTPULSEPOS = 1; // Set pulse positions to late
AdccRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up the ADC
EDIS;
DELAY_US(1000); // Delay for 1ms to allow ADC time to power up
}
Here is my main which handles the mapping and etc, in case there is an error in that anyone can identify:
void main(void)
{
InitSysCtrl(); // Initialise System Control (F2837xD_SysCtrl.c)
EALLOW;
ClkCfgRegs.PERCLKDIVSEL.bit.EPWMCLKDIV = 0; // Set EPWM clock equal to PLLSYSLCK
EDIS;
// May need to enable also the HRPWM clock on CPU1 if to use SFO functions
// Calling SFO() updates the HRMSTEP register with calibrated MEP_ScaleFactor.
// HRMSTEP must be populated with a scale factor value prior to enabling
// high resolution period control.
while(status == SFO_INCOMPLETE)
{
status = SFO();
if(status == SFO_ERROR)
{
error(); // SFO function returns 2 if an error
InitGpioPins();
// Clear all interrupts and initialise PIE vector table
DINT;
InitPieCtrl(); // Clear all ENPIE bit and PIEIERx PIEIFRx register
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// Put C28x ISR addresses in vector table
// ADC interrupts go through PIE (Group 1)
EALLOW;
PieVectTable.EPWM1_INT = &MainCPU_ISR; // Test PWM interrupt
//PieVectTable.ADCA1_INT = &MainCPU_ISR; // Insert vector for INT1 of ADCA for Cathode Voltage Regulator ISR
PieVectTable.TIMER0_INT = &Soft_start; // Insert vector for Timer interrupt that causes increment in soft-start
//PieVectTable.ADCA2_INT = &auxCPU_ISR; // Insert vector for INT2 of ADCA for Collector Voltage Regulator ISR + write info
PieVectTable.EPWM4_INT = &auxCPU_ISR; // Test PWM4 Interrupt to check ADC errors
PieVectTable.IPC0_INT = &ipc0_isr; // Insert vector for CPU1 <--> CPU2 communications interrupt and update LCC registers
EDIS;
// Clear all IPC Bits to start
IpcRegs.IPCCLR.all = 0xFFFFFFFF;
// CPU1 Function Prototypes
InitADCs(); // Initialise all ADC Units
InitDACs(); // Initialise all DAC Units
InitCMPSS1(); // Initialise the second Comparator sub-system
InitCMPSS2(); // Initialise the second Comparator sub-system
InitCMPSS3(); // Initialise the third Comparator sub-system
InitCMPSS5(); // Initialise the fifth Comparator sub-system
InitCMPSS6(); // Initialise the sixth Comparator sub-system
InitEpwmXbar(); // Initialise the ePWM Crossbar
SetupSOC(); // Configure the Start of Conversions
InitPPB(); // Initialise Post Processing Block
// Stop time-base clock until all PWM channels are set up
EALLOW;
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
EDIS;
// Set up PWM Modules
InitEPwm1(); // Initialise module 1
InitEPwm4(); // Initialise module 4
// Configure CLA memory spaces and CLA task vectors
CLA_configClaMemory();
CLA_initCpu1Cla1();
Cla1ForceTask8andWait(); // Run the CLA Task 8 macro via SW to initialise CLA global variables
// Enable global interrupts and higher priority real-time debug events:
IER |= M_INT1; // Enable group 1 interrupts
IER |= M_INT3; // Enable PIE group 3 interrupt (EPWM1 to EPWM12)
IER |= M_INT10; // Enable group 10 interrupts
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global real-time interrupt DBGM
// Need to manually enable our interrupts
// Unsure whether we need the IPC1 ISR, since we
// trigger the IPC ISR with ADCA2 as of now
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable ADCA1 interrupt for triggering Cathode CLA Routine
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // Enable Timer 0 interrupt for soft-start
PieCtrlRegs.PIEIER1.bit.INTx13 = 1; // Enable IPC1 ISR which is used for collector and IPC ISR
PieCtrlRegs.PIEIER10.bit.INTx2 = 1; // Enable ADCA2 interrupt for triggering collector and IPC ISR
PieCtrlRegs.PIEIER3.bit.INTx1 = 1; // Enable PWMINT1 interrupt
PieCtrlRegs.PIEIER3.bit.INTx4 = 1; // Enable PWMINT4 interrupt
// Wait here until CPU02 is ready
// Statement does nothing until CPU02 is ready
while (IpcRegs.IPCSTS.bit.IPC17 == 0) ; // Wait for CPU02 to set IPC17
IpcRegs.IPCACK.bit.IPC17 = 1; // Acknowledge and clear IPC17
// Timer functions
Timer0_Init(); // Initialise timer 0 - will be used for main ISR. Timer begins in the initialisation function
// Start time-base clock so that all PWM channels are synchronised (must occur after all PWMs initialised)
EALLOW;
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
EDIS;
// Infinite while loop forever
while(1)
{
;
}
}
I am out of ideas why this isn't working. I have no input signals when debugging - but I would assume the interrupts would still be generated despite there being no inputs to the sensors. I also though it may be because my initail duty cycles in the CMPA registers were set to 0, however I made those a random number to ensure at least the first PWM cycle could trigger an ISR, but again I have no luck.
Any and all ideas are welcome!
Joel