RX610 external IRQs only trigger once then ICU doesn’t respond
RX610 external IRQs only trigger once then ICU doesn’t respond
Hello,
I’m using an RX610 Stick board, I need to trigger a process from an external IRQ, for now I’m using one of the onboard push buttons as interrupt source, this button is connected to a pin assigned as IRQ7-B.
After system reset, all other modules work ok (power, led panel, UART – which uses an IRQ for rx-, etc). When I press the button for the 1st time, the interrupt controller detects it, executes the correspondent IRQ handler correctly and returns to the main program loop, but after that, no other IRQs are detected anymore, so if I press the button again nothing happens, even the UART RX – which is also IRQ based and before pressing the button was working ok – now doesn’t work (not detected). Seems like the ICU gets stuck after the irq was executed.
The code I’m using for now is very simple and goes like this:
After reset I configure the pin P1_7 for the button as:
PORT1.DDR.BIT.B7 = 0; // set pin as input
ICU.IER[8].BIT.IEN7 = 0; // IRQ7 temporarily disabled
IOPORT.PFCR9.BIT.ITS7 = 1; // P17 is designated as IRQ7-B
PORT1.ICR.BIT.B7 = 1; // P17 buffer enable
ICU.IRQCR[7].BYTE = 8; // IRQ7 detect on rising edge
ICU.IPR[0x27].BYTE = 5; // IRQ7 priority level 5
ICU.IR[71].BYTE = 0; // IRQ7 clear flag
ICU.IRQER[7].BYTE = 1; // IRQ7 detection enabled
ICU.IER[8].BIT.IEN7 = 1; // IRQ7 enable
Here’s the IRQ7 handler:
void INT_Excep_IRQ7(void){gFlags |= 1;}
And in the main loop I have:
if (gFlags & 1) { PORTE.DR.BYTE ^= 0x1; // led toggle }
As mentioned, only the first time I press the button the handler is executed (led toggles), further pressings don’t do anything. The main loop is not hanged (other functions work ok), but anything that involves the interrupt controller doesn’t work (e.g. UART RX doesn’t work).
Any suggestions?
thanks
Hello,
Unfortunately, our team’s support is limited to toolchain related problems, problems with the compiler, libraries and other pertaining items, therefore configuring peripherals is outside the scope of our support.
The official Renesas website offers app notes for most peripheral functions, also the application development community is available at Renesas Rulz forum at https://renesasrulz.com.
As a courtesy we have reproduced your configuration in e2 Studio targeting the RX64M family. We have chosen RX64M because it has Peripheral Code Generator from Renesas. Here are the results from the code generator:
void R_ICU_Create(void) {
/* Disable IRQ interrupts */ ICU.IER[8].BYTE = 0; ICU.IER[9].BYTE = 0;
/* Set IRQ settings */ ICU.IRQCR[7].BYTE = 8;
/* Set IRQ7 priority level */ ICU.IPR[71].BIT.IPR = 5;
/* Set IRQ7 pin */ MPC.P17PFS.BYTE = 0x40U; PORT1.PDR.BYTE &= 0x7FU; PORT1.PMR.BYTE &= 0x7FU;
}
void R_ICU_IRQ7_Start(void) {
/* Enable IRQ7 interrupt */ ICU.IER[8].BIT.IEN7 = 1U;
}
We hope this is of help. If you have any other questions, please let us know.
__
Best regards,
The GNU Tools Team
Hello,
The sample code and example projects are all maintained by Renesas, it should be enough to add interrupt attribute to the function declaration (prototype) only.
It is a bit counter intuitive that the function definition (implementation) does not have the interrupt attribute, but it is done like this in all samples and generated code, according to the principle that every function that is used in different files is shared via its declaration in a header file.
We managed to reproduce it on our RX64M reproduction of your project, however you did not include the interrupt vector header in the file where you implemented INT_Excep_IRQ7().
Please try including interrupt_handlers.h in your file and discard the interrupt attribute from function definition void INT_Excep_IRQ7(void) and let us know if it works correctly.
—
Regards,
The GNU Tools Team