Part Number: EVMK2G
Other Parts Discussed in Thread: SYSBIOS
Dear experts,
for my work I am developping a bare metal code on the evaluation board EVMK2G that is loaded in the DSP C66x by means of the on-board debugger TI XDS2xxx.
I downloaded the ti-processor-sdk-rtos-k2g-evm-06.03.00.106-Windows-x86-Install.exe and I installed CCS10.2
My application deals with a motor control by means of 2 EPWM signals.
I properly programmed the EPWM1 and EPWM2 modules. Each module triggers the corresponding ISR by means of INTC and CIC modules.
EPWM1 triggers the ISR1 that controls its period. ISR1 is very short and has the priority 4. It is mapped on CIC_OUT_33.
EPWM2 triggers the ISR2 that controls its period. ISR2 is long and has the priority 5. It is mapped on CIC_OUT_34.
I have problems with the nesting of ISR1 inside ISR2. In particular, when ISR1 nests the ISR2, the period of EPWM2 is wrong.
The problem disappears if I disable the nesting of ISR1 inside ISR2.
void ISR1void) //ISR triggered by the module EPWM1
{
unsigned int old_csr;
unsigned int old_irp;
unsigned int old_itsr, old_ier;
static int v;
old_irp = IRP ;// Save IRP
old_csr = CSR ;// Save CSR (and thus PGIE)
old_itsr = ITSR; // Save ITSR
old_ier = IER; // Save IER
IER=0x0;
for(v = 0; v < 4; v++) {IER |= (1 << v);};
CSR = old_csr | 1 ; // Enable interrupts
/* period_regulation code */
HW_WR_REG32(CSL_CIC_0_REGS + CSL_CPINTC_STATUS_CLR_INDEX_REG, (uint32_t)CSL_CIC_EPWM_1_INT); // Clear the status of the CIC system interrupt number 201 (EPWM_1_INT)
HW_WR_REG16(CSL_PWM_1_CFG_REGS + PWMSS_EPWM_ETCLR, 0x1); // Clear the ETFLG register of the module EPWM1
CSR = CSR & -2 ; // Disable interrupts
CSR = old_csr ; // Restore CSR (and thus PGIE)
ITSR = old_itsr; // Restore ITSR
IER = old_ier; // Restore IER
IRP = old_irp ; // Restore IRP
}
void ISR2void) //ISR triggered by the module EPWM2
{
unsigned int old_csr;
unsigned int old_irp;
unsigned int old_itsr, old_ier;
static int v;
old_irp = IRP ;// Save IRP
old_csr = CSR ;// Save CSR (and thus PGIE)
old_itsr = ITSR; // Save ITSR
old_ier = IER; // Save IER
IER=0x0;
for(v = 0; v < 5; v++) {IER |= (1 << v);};
CSR = old_csr | 1 ; // Enable interrupts
/* period_regulation code */
HW_WR_REG32(CSL_CIC_0_REGS + CSL_CPINTC_STATUS_CLR_INDEX_REG, (uint32_t)CSL_CIC_EPWM_2_INT); // Clear the status of the CIC system interrupt number 202 (EPWM_2_INT)
HW_WR_REG16(CSL_PWM_2_CFG_REGS + PWMSS_EPWM_ETCLR, 0x1); // Clear the ETFLG register of the module EPWM2
CSR = CSR & -2 ; // Disable interrupts
CSR = old_csr ; // Restore CSR (and thus PGIE)
ITSR = old_itsr; // Restore ITSR
IER = old_ier; // Restore IER
IRP = old_irp ; // Restore IRP
}
The TRM SPRUHY8I reports the following suggestion:
If the host can accept other host interrupts while processing the ISR then disabling all the host interrupts(in Step 2) would be suggested, assuming the ISR only wants to process one interrupt at a time. There is
a global control bit (bit [0] in Global Enable Register) to enable/disable all the host interrupts to make theprocess easier (the individual host interrupt enables are maintained as well).
Is it possible to nest two ISRs by means of CIC module?
Best regards,
Benito