Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE
Hello,
I have an application where three GPIO toggle events must be captured by their respective interrupt handlers. To enable the registers I use the following procedure (simplified):
- During startup, call the initialization function
#define GPIO_PIN_A 36
#define GPIO_PIN_B 37
#define GPIO_PIN_C 38
void init()
{
// link xinput to xint
InputXbarRegs.INPUT6SELECT = GPIO_PIN_A;
InputXbarRegs.INPUT13SELECT = GPIO_PIN_B;
InputXbarRegs.INPUT14SELECT = GPIO_PIN_C;
// Attach isr handlers
IntRegister(INT_XINT3, isrA);
IntRegister(INT_XINT4, isrB);
IntRegister(INT_XINT5, isrC);
}
- After initialization, the interrupts can be enabled or disabled by the user. The user has two interfaces to enable or disable the feature that uses the GPIOs (Start and Stop)
void start()
{
// Disable XINT
XINT_REGS.XINT3CR.bit.ENABLE = 0x0U;
XINT_REGS.XINT4CR.bit.ENABLE = 0x0U;
XINT_REGS.XINT5CR.bit.ENABLE = 0x0U;
// Set prescaler in GPIO
GpioCtrlRegs.GPBCTRL.bit.QUALPRD0 = 1;
// Configure inputs as 3-Sample qualification
GPIO_SetupPinOptions(GPIO_PIN_A, GPIO_INPUT, GPIO_QUAL3);
GPIO_SetupPinMux(GPIO_PIN_A, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(GPIO_PIN_B, GPIO_INPUT, GPIO_QUAL3);
GPIO_SetupPinMux(GPIO_PIN_B, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(GPIO_PIN_C, GPIO_INPUT, GPIO_QUAL3);
GPIO_SetupPinMux(GPIO_PIN_C, GPIO_MUX_CPU1, 0);
// Configure xint polarity bit
XINT_REGS.XINT3CR.bit.POLARITY = 0x3U;
XINT_REGS.XINT4CR.bit.POLARITY = 0x3U;
XINT_REGS.XINT5CR.bit.POLARITY = 0x3U;
// Enable XINT
XINT_REGS.XINT3CR.bit.ENABLE = 0x1U;
XINT_REGS.XINT4CR.bit.ENABLE = 0x1U;
XINT_REGS.XINT5CR.bit.ENABLE = 0x1U;
// Enable XINT in PIE
IntEnable(INT_XINT3);
IntEnable(INT_XINT4);
IntEnable(INT_XINT5);
}
void stop()
{
// Disable XINT in PIE
IntDisable(INT_XINT3);
IntDisable(INT_XINT4);
IntDisable(INT_XINT5);
// Disable xint
XINT_REGS.XINT3CR.bit.ENABLE = (uint16_t)0x0U;
XINT_REGS.XINT4CR.bit.ENABLE = (uint16_t)0x0U;
XINT_REGS.XINT5CR.bit.ENABLE = (uint16_t)0x0U;
}
The problem is that sometimes, after startup and calling the function start(), the application seems to ignore real GPIO transitions. I configured two extra GPIOs as outputs to debug the ISR handlers and I can confirm that the ISR handler is not triggered. The user needs to call stop() and start() functions again to workaround the issue. Besides, the isr attached to the GPIO interrupt with the last real transition is triggered. For example, if a real transition in the GPIO_PIN_B is lost, then the isrB handler is called after restarting the interrrupts.
Investigating a bit further, I discovered that when the issue appears, the PIEIER flag for the specified GPIOs is disabled at some point, and this happens without a prior call of the stop() function. That's why when the user reconfigure the interrupts with a stop()/start() process, everything works again.
I was not able to find any way in the code to disable PIEIER flags without calling the stop() function. Is there a way in which this flag can be reset for some reason?
BTW, the issue is not easy to reproduce, most of the times the startup sequence is ok. After restarting the interrupts again, the problem does not appear anymore.
Thanks for your help
Regards,
Luis