Translation - English: PSoC 4 SCB コンポーネントの内部割込みの使用方法 - KBA222371- Community Translated (JA)
How to Use the Internal Interrupt of the UART (SCB) Component in PSoC® 4?
When the internal interrupt of the SCB is enabled, the SCB Component adds an internal ISR Component, which is called SCB_IRQ. PSoC Creator will generate the corresponding APIs for this ISR Component automatically. You can use the UART_SetCustomInterruptHandler(InterruptHandUart) API to set the vector of your own function to this interrupt, where InterruptHandUart is the user-defined vector for your own interrupt function.
The internal schematic of the SCB component
At the same time, the SCB_IRQ interrupt is internally used for the UART Component. The device performs internal functions such as software buffer management in the SCB_IRQ interrupt (see the Component datasheet: “The interrupt mode is automatically set to internal and the RX FIFO not empty interrupt source is reserved to manage software buffer operation: move data from the RX FIFO into the circular software buffer.”) You can also find the following code in the CY_ISR(UART_SPI_UART_ISR) function in the UART_SPI_UART_INT.C file.
If you enable the internal interrupt for the SCB UART Component, you can add your own function in the interrupt by using the UART_SetCustomInterruptHandler(InterruptHandUart) API in PSoC Creator. The API adds the user-defined function to the interrupt routine in front of the system-defined function (the buffer management function). You can find the code in the CY_ISR(UART_SPI_UART_ISR) function in the UART_SPI_UART_INT.c file as follows:
(The UART_SPI_UART_ISR is the internal used interrupt handler for the SCB_ISR interrupt. The UART_customIntrHandler is the userdefined function.
#endif /* (UART_INTERNAL_RX_SW_BUFFER_CONST) */
#endif /* (UART_INTERNAL_TX_SW_BUFFER_CONST) */
#endif /* UART_SPI_UART_ISR_ENTRY_CALLBACK */
if (NULL != UART_customIntrHandler)
The interrupt vector UART_SPI_UART_ISR is set to the SCB_ISR interrupt in the UART_UART.c file with the following code which has the same meaning as UART_SCB_IRQ_StartEx(UART_SPI_UART_ISR):
You can find the UART_SCB_IRQ_StartEx(InterruptHandUart) API in the UART_SCB_IRQ.c file. This API is automatically generated by PSOC Creator. If you use the UART_SCB_IRQ_StartEx(InterruptHandUart) API to set the interrupt handler, the system-defined function UART_SPI_UART_ISR will be replaced by the user-defined function InterruptHandUart. In this condition, the buffer management function will not be executed which may lead to a faulty operation of the UART.
Therefore, it is recommended that you use the UART_SetCustomInterruptHandler(InterruptHandUart) API to add your own function to the internal interrupt. The UART_SCB_IRQ_StartEx(InterruptHandUart) should not be used.
The usage of the APIs is the same with other SCBs such as SPI and I2C.
See the following application note for a better understanding: http://www.cypress.com/documentation/application-notes/an90799-psoc-4-interrupts