Rev. 1.00
1�0
��ne ��� �01�
Rev. 1.00
1�1
��ne ��� �01�
HT66FM5440
Brushless DC Motor A/D Flash MCU
HT66FM5440
Brushless DC Motor A/D Flash MCU
The following example explains how the program runs when both preempt functions are enabled by
setting the INTPRI1~INTPRI0 bits to 11B.
04H
08H
0CH
10H
Main loop
High
Priority
System clock
1
2
3 4
5
6
7
8
Interrupt
Vector
1
Vector 10H preempts the main loop.
2 Exits vector 10H subroutine and returns to the main loop.
3 Vector 0CH preempts the main loop.
4 The second highest priority 08H preempts the 0CH subroutine.
5 The first highest priority 04H preempts the 08H subroutine.
6 Exits vector 04H subroutine by "RETI" and go no to execute the 08H subroutine.
7 Exits vector 08H subroutine by "RETI" and go no to execute the 0CH subroutine.
8
Exits vector 0CH subroutine by "RETI" and returns to the main loop.
Interrupt Operation
When the conditions for an interrupt event occur, such as a TM Comparator P or Comparator A
match or A/D conversion completion etc., the relevant interrupt request flag will be set. Whether
the request flag actually generates a program jump to the relevant interrupt vector is determined by
the condition of the interrupt enable bit. If the enable bit is set high then the program will jump to
its relevant vector; if the enable bit is zero then although the interrupt request flag is set an actual
interrupt will not be generated and the program will not jump to the relevant interrupt vector. The
global interrupt enable bit, if cleared to zero, will disable all interrupts.
When an interrupt is generated, the Program Counter, which stores the address of the next instruction
to be executed, will be transferred onto the stack. The Program Counter will then be loaded with a
new address which will be the value of the corresponding interrupt vector. The microcontroller will
then fetch its next instruction from this interrupt vector. The instruction at this vector will usually
be a "JMP" which will jump to another section of program which is known as the interrupt service
routine. Here is located the code to control the appropriate interrupt. The interrupt service routine
must be terminated with a "RETI", which retrieves the original Program Counter address from
the stack and allows the microcontroller to continue with normal execution at the point where the
interrupt occurred.
Some interrupt sources have their own individual interrupt number while others share the same
interrupt number. Once an interrupt subroutine is serviced, all the other interrupts except the
interrupt vector 04H or 08H with their interrupt preempt function enabled, will be blocked, as the
global interrupt enable bit, EMI bit will be cleared automatically. This will prevent any further
interrupt nesting from occurring. However, if other interrupt requests occur during this interval,
although the interrupt will not be immediately serviced, the request flag will still be recorded.