跳至主要內容
Knowledgebase
Home
Renesas Electronics Taiwan - Knowledgebase

How to Change Process for Next Interrupt per Processing State

Last Updated:05/25/2018

Question:

Depending on the processing state, a different process needs to be executed for the next interrupt request even if that interrupt is the same type. Therefore, we have provided a flag in order to branch the program by referencing that flag inside interrupt processing. However, depending on the processing content, the time it takes for the program to branch and start processing will vary. Isn't it possible to dynamically rewrite the interrupt vector value?

Answer:

The interrupt vector itself cannot be re-written. However, a process such as that described below can handle the situation.
Prepare a variable in which to set the address of the actual processing area in the short direct field, and store in advance the address of the processing area to be processed with the next interrupt. If an interrupt is accepted in this state, that variable is read and the program is branched to that address. In this way, the time it takes from interrupt acceptance to the actual processing is always the same.
Specifically, DSEG is declared in the saddr attribute to secure a 2-byte field (Intaddr in this case) as described below.

        DSEG    saddrp
Intaddr:
        DW      2               ;Interrupt processing address storage field
Next, the following process is executed at the beginning of the interrupt processing:
INTxxx:
        PUSH    AX              ;Save the content of the AX register to the stack.
;
; As needed, other registers to be used in the interrupt are saved in the stack.
;
        MOVW    AX,Intaddr      ;Read the processing address
        BR      AX              ;Branch to the processing address

Now, the program can branch to the actual interrupt processing area while the AX (and other) register(s) are saved in the stack. Since this processing is constant regardless of the actual content to be processed by an interrupt, it satisfies the requirement.
 
There is also a method that uses a flag and table reference to acquire the address to be actually processed, and branches the program to that address. However, to minimize as much as possible the delay following the generation of an interrupt, the above-mentioned method, which sets the processing address in a variable in advance, is more advantageous.

Suitable Products
RL78/G10
RL78/G11
RL78/G12
RL78/G13
RL78/G14
RL78/G1A
RL78/G1C
RL78/G1D
RL78/G1E
RL78/G1F
RL78/G1G
RL78/G1H
RL78/I1A
RL78/I1C
RL78/I1D
RL78/I1E
RL78/L12
RL78/L13
RL78/L1A
RL78/L1C
78K Family
  • 本文是否實用?