9. Interrupt

9. Interrupt

The CH559 chip supports 14 sets of interrupt signal sources, including 6 sets of interrupts compatible with the standard MCS51: INT0, T0, INT1, T1, UART0, T2, and extended 8 sets of interrupts: SPI0, TMR3, USB, ADC, UART1, PWM1 GPIO, WDOG, among which GPIO interrupt can be selected from 7 I/O pins.

9.1 Register description

Table 9.1.1 Interrupt vector table

Interrupt SourceEntry AddressInterrupt numberDescriptionDefault priority
INT_NO_INT00x00030

External interrupt 0 or LED control card interrupt:

When bLED_OUT_EN = 0 is external interrupt 0;

When bLED_OUT_EN = 1 is LED control card interrupt

High priority
































Low priority
INT_NO_TMR00x000B1Timer 0 interrupt
INT_NO_INT10x00132External interrupt 1
INT_NO_TMR10x001B3Timer 1 interrupt
INT_NO_UART00x00234UART0 interrupt
INT_NO_TMR20x002B5Timer 2 interrupt
INT_NO_SPI00x00336SPI0 interrupt
INT_NO_TMR30x003B7Timer 3 interrupt
INT_NO_USB0x00438USB interrupt
INT_NO_ADC0x004B9ADC interrupt
INT_NO_UART10x005310UART1 interrupt
INT_NO_PWM10x005B11PWM1 interrupt
INT_NO_GPIO0x006312GPIO interrupt
INT_NO_WDOG0x006B13Watchdog timer interrupt

Table 9.1.2 Interrupt related register list

NameAddressDescriptionReset value
IP_EXE9hExtended interrupt priority control register00h
IE_EXE8hExtended interrupt enable register00h
GPIO_IECFhGPIO interrupt enable register00h
IPB8hInterrupt Priority Control Register00h
IEA8hinterrupt enable register00h

Interrupt Enable Register (IE):

BitNameAccessDescriptionReset value
7EARWGlobal interrupt enable control bit, this bit is 1 and E_DIS is 0 to enable interrupts. this bit is 0 to mask all interrupt requests0
6E_DISRWGlobal interrupt disable control bit, this bit is 1 to mask all interrupt requests. this bit is 0 and EA is 1 to enable interrupts. This bit is typically used to temporarily disable interrupts during flash-ROM operations0
5ET2RWTimer 2 interrupt enable bit, this bit is 1 to enable T2 interrupt. it is 0 to mask0
4ESRWAsynchronous serial port 0 interrupt enable bit, this bit is 1 to enable UART0 interrupt. masked to 00
3ET1RWTimer 1 interrupt enable bit. This bit is 1 to enable the T1 interrupt. it is masked to 0.0
2EX1RWExternal interrupt 1 enable bit, this bit is 1 to enable the INT1 interrupt. masked to 00
1ET0RWTimer 0 interrupt enable bit, this bit is 1 to enable the T0 interrupt. masked to 00
0EX0RWExternal interrupt 0 and LED control card interrupt enable bit, this bit is 1 to enable INT0 / LED interrupt, selected by bLED_OUT_EN. masked to 00

Extended interrupt enable register (IE_EX):

BitNameAccessDescriptionReset value
7IE_WDOGRWWatchdog timer interrupt enable bit, this bit is 1 to enable WDOG interrupt; 0 to mask0
6IE_GPIORWGPIO interrupt enable bit, this bit is 1 to enable interrupts enabled in GPIO_IE; 0 to mask all interrupts in GPIO_IE0
5IE_PWM1RWPWM1 interrupt enable bit. This bit is 1 to enable PWM1 interrupt; 0 to mask 00
4IE_UART1RWasynchronous serial port 1 interrupt enable bit, this bit is 1 to enable UART1 interrupt; 0 to mask0
3IE_ADCRWADC analog-to-digital conversion interrupt enable bit, this bit is 1 to enable ADC interrupt; 0 to mask0
2IE_USBRWUSB interrupt enable bit, this bit is 1 to enable USB interrupt; 0 to mask0
1IE_TMR3RWTimer 3 interrupt enable bit, this bit is 1 to enable Timer3 interrupt; 0 to mask0
0IE_SPI0RWSPI0 interrupt enable bit, this bit is 1 to enable SPI0 interrupt; 0 to mask0

GPIO interrupt enable register (GPIO_IE):

BitNameAccessDescriptionReset value
7bIE_IO_EDGERW

GPIO edge interrupt mode enable:

This bit is 0 to select the level interrupt mode.If the GPIO pin input valid level, bIO_INT_ACT is 1 and the interrupt is always requested.When the GPIO input invalid level, bIO_INT_ACT is 0 and the interrupt request is canceled.

This bit is 1 to select the edge interrupt mode. When a valid edge is input to the GPIO pin, the interrupt flag bIO_INT_ACT is generated and an interrupt is requested. This interrupt flag cannot be cleared by software. It can only be reset or in level interrupt mode or enter the corresponding interrupt service routine Is automatically cleared

0
6bIE_RXD1_LORWThis bit is 1 to enable UART1 receive pin interrupt (level mode is active low, edge mode falling edge is active). this bit is 0 to disable. Select XA/XB differential input in iRS485 mode, select RXD1 or RXD1_ pin according to bIER_PIN_MOD1 = 1/0 in non-iRS485 mode0
5bIE_P5_5_HIRWThis bit is 1 to enable the P5.5 interrupt (level mode is active high and edge mode is active on rising edge); this bit is 0 to disable0
4bIE_P1_4_LORWThis bit is 1 to enable the P1.4 interrupt (level mode is active low, edge mode is active on falling edge); this bit is 0 to disable0
3bIE_P0_3_LORWThis bit is 1 to enable the P0.3 interrupt (active in low level in level mode and valid in falling edge in edge mode); this bit is 0 to disable0
2bIE_P5_7_HIRWThis bit is 1 to enable the P5.7 interrupt (level mode is active high and edge mode is active on rising edge); this bit is 0 to disable0
1bIE_P4_1_LORWThis bit is 1 to enable the P4.1 interrupt (active in low level in level mode and valid in falling edge in edge mode); this bit is 0 to disable0
0bIE_RXD0_LORWThis bit is 1 to enable the UART0 receive pin interrupt (level mode is active low, edge mode is active falling edge); this bit is 0 to disable. Select RXD0 or RXD0_ pin according to bUART0_PIN_X = 0/10

Interrupt Priority Control Register (IP):

BitNameAccessDescriptionReset value
7PH_FLAGR0High priority interrupt executing flag0
6PL_FLAGR0Low Priority Interrupt Execution Flag0
5PT2RWTimer 2 interrupt priority control bit0
4PSRWUART0 interrupt priority control bit0
3PT1RWTimer 1 interrupt priority control bit0
2PX1RWInterrupt priority control bit for external interrupt 10
1PT0RWtimer 0 interrupt priority control bit0
0PX0RWExternal Interrupt 0 and Interrupt Priority Control Bit for LED Control Card Interrupt0

Extended interrupt priority control register (IP_EX):

BitNameAccessDescriptionReset value
7bIP_LEVELR0Current interrupt nesting level flag bit. If this bit is 0, it means no interrupt or nested level 2 interrupt.If this bit is 1, it means current nested level 1 interrupt.0
6bIP_GPIORWGPIO interrupt priority control bit0
5bIP_PWM1RWPWM1 interrupt priority control bit0
4bIP_UART1RWUART1 interrupt priority control bit0
3bIP_ADCRWADC interrupt priority control bit0
2bIP_USBRWUSB interrupt priority control bit0
1bIP_TMR3RWTimer3 interrupt priority control bit0
0bIP_SPI0RWSPI0 interrupt priority control bit0

The IP and IP_EX registers are used to set the interrupt priority. If a bit is set to 1, the corresponding interrupt source is set to a high priority. If a bit is cleared to 0, the corresponding interrupt source is set to a low priority . For the same level interrupt source, the system has a default priority order. The default priority order is shown in Table 9.1.1. Its PH_FLAG and PL_FLAG combination indicates the priority of the current interrupt.

Table 9.1.3 Current interrupt priority status indication

PH_FLAGPL_FLAGCurrent interrupt priority status
00No interruption currently
01Low priority interrupt is currently executing
10High priority interrupt is currently executing
11Unexpected state, unknown error