The present disclosure relates to microprocessors or microcontrollers.
Microcontrollers are single chip systems on a chip comprising a central processing unit (CPU), memory, I/O interfaces and a plurality of different peripheral devices such as serial interfaces, analog-to-digital converters. PWM modulators, timers, etc. Generally, many applications do not require a lot of processing power. Thus to keep costs low, certain microcontrollers, such as 8-bit microcontrollers with a limited amount of program memory and data memory often are implemented without any type of external or internal interrupts or with a limited number of interrupts due to the fact that such interrupt logic requires significant real estate on a die. For example a baseline microcontroller family of a manufacturer may include devices that do not comprise any interrupt capability or only a single interrupt. A mid-range family may be designed to allow for a single interrupt and an associated interrupt controller that receives a plurality of interrupts and generates an output signal fed to the single interrupt input of the CPU. Both of these microcontroller types may comprise a CPU with single interrupt input wherein when asserted causes the program execution to finish a currently pending instruction and then branch to a defined address (interrupt vector), e.g. address 0004h. A higher end family of microcontrollers of the manufacturer may include devices with a CPU that has two interrupt inputs one being assigned a low priority and one being assigned a high priority as well as an interrupt controller for distributing interrupts from various sources to these two interrupt inputs of the CPU.
The present application thus focuses on microcontrollers comprising a central processing unit that has a limited number of interrupts, e.g. a single or two interrupt inputs and associated interrupt controller with a limited interrupt functionality. In many applications this may still not be sufficient and a higher end device, for example a 16-bit or 32-bit microcontroller must be chosen due to the fact that the interrupt capabilities of the 8-bit microcontrollers are too limiting. Also, if such microcontrollers are intended to have an increased number of peripherals the central processing unit may not be able to support an associated interrupt function due to the limited interrupt functionality.
Hence, there exists a need for a microcontroller with an improved or more flexible interrupt handling.
According to an embodiment, a microcontroller may comprise a central processing unit comprising at least one interrupt input, an interrupt controller configured to provide at least one interrupt signal to the at least one interrupt input of the central processing unit, a plurality of peripherals coupled with the central processing unit and the interrupt controller, and a mode register comprising at least one bit controlling an operating mode of the microcontroller, wherein the microcontroller is configured to operate in a first and in a second mode, wherein in the first operating mode upon assertion of an interrupt by a peripheral of the microcontroller, the interrupt controller forwards an interrupt signal to the central processing unit and the peripheral sets an associated interrupt flag, wherein the interrupt causes the central processing unit to branch to a predefined interrupt address associated with the interrupt input, wherein in the second operating mode upon assertion of an interrupt by a peripheral of the microcontroller, the interrupt controller forwards an interrupt signal to the central processing unit and the central processing unit receives additional interrupt information from the peripheral that generated the interrupt, wherein the additional interrupt information is used to generate a vector address.
According to a further embodiment, in the second operating mode, after receiving an interrupt, the central processing unit can be configured to perform a context save before entering a service routine and wherein a register of the central processing unit receives data configured to identify an interrupt source after said context save. According to a further embodiment, the register can be a working register of the arithmetic logic unit. According to a further embodiment, said additional information provided by a peripheral that generated the interrupt can be used to shift a constant value and wherein the shifted constant value is moved into the register. According to a further embodiment, said additional information can be an interrupt number which is directly stored in a working register of the CPU. According to a further embodiment, in the second operating mode, a base register can be provided that stores a base address and an offset address depending on an interrupt source is forwarded to the central processing unit, wherein an interrupt vector is generated by adding the vector address to the base address stored in the base register. According to a further embodiment, in the second mode, the microcontroller can be programmed to provide for an interrupt service routine that evaluates the content of the working register to branch to a respective service routine associated with an interrupt source that generated the interrupt. According to a further embodiment, in the first mode, the microcontroller can be programmed to provide for an interrupt service routine that polls an interrupt flag in a special function register to determine an interrupt source that generated the interrupt. According to a further embodiment, the central processing unit may comprise only a single interrupt input. According to a further embodiment, the central processing unit may comprise only a first and a second interrupt input, wherein the first interrupt input has a higher priority than the second interrupt input. According to a further embodiment, when a higher priority interrupt interrupts a lower priority service routine, the higher priority interrupt can be configured to clear a lower priority interrupt and an associated service routine returns directly to a main code without returning through the low priority service routine. According to a further embodiment, when a higher priority interrupt interrupts a lower priority service routine, the higher priority interrupt can be configured to return directly to the lower priority interrupt service routine without returning to a main code. According to a further embodiment, interrupt controller may comprise controllable logic to enable interrupts received from the peripherals.
According to another embodiment, a method for providing interrupt functionality within a microcontroller comprising a central processing unit comprising at least one interrupt input and an interrupt controller configured to provide at least one interrupt signal to the at least one interrupt input of the central processing unit, may comprise the steps of: setting a first or a second operating mode; receiving an interrupt by the interrupt controller; and when operating in the first operating mode, forwarding by the interrupt controller an interrupt signal to the central processing unit and setting an associated interrupt flag, wherein the interrupt causes the central processing unit to branch to a predefined interrupt address associated with the interrupt input; and when operating in the second operating mode, forwarding by the interrupt controller an interrupt signal to the central processing unit and receiving by the central processing unit additional interrupt information from the peripheral that generated the interrupt, wherein the additional interrupt information is used to generate a vector address.
According to a further embodiment of the method, in the second operating mode, after receiving an interrupt, the method may perform a context save before entering a service routine and receiving additional information by the central processing unit configured to identify an interrupt source after said context save and storing said additional information or data derived from said additional information in a register. According to a further embodiment of the method said additional information can be an interrupt number which is directly stored in a working register of the CPU. According to a further embodiment of the method, the method may further comprise the step of calculating an address after entering the service routine using said data and branching to said address to service said interrupt. According to a further embodiment of the method said data may be used to shift a constant value and wherein the shifted constant value is moved into the register. According to a further embodiment of the method, the method may further comprise the step of using said shifted value as an offset address to branch to an address to service said interrupt. According to a further embodiment of the method, in the second operating mode a base register may be provided that stores a base address and an offset address depending on an interrupt source is forwarded to the central processing unit, and generating an interrupt vector by adding the vector address to the base address stored in the base register. According to a further embodiment of the method, in the second operating mode, an interrupt service routine may evaluate the content of the working register to branch to a respective address providing instructions associated with an interrupt source that generated the interrupt. According to a further embodiment of the method, in the first mode, an interrupt service routine may poll an interrupt flag in a special function register to determine an interrupt source that generated the interrupt. According to a further embodiment of the method, the central processing unit may comprise only a single interrupt input. According to a further embodiment of the method, the central processing unit may comprise only a first and a second interrupt input, wherein the first interrupt input has a higher priority than the second interrupt input. According to a further embodiment of the method, when a higher priority interrupt interrupts a lower priority service routine, the higher priority interrupt may be configured to clear a lower priority interrupt and an associated service routine may return directly to a main code without returning through the low priority service routine. According to a further embodiment of the method, when a higher priority interrupt interrupts a lower priority service routine, the higher priority interrupt may be configured to return directly to the lower priority interrupt service routine without returning to a main code.
According to yet another embodiment, a microcontroller may comprise a central processing unit comprising at least one interrupt input and a register coupled with an arithmetic logic unit; an interrupt controller configured to provide at least one interrupt signal to the at least one interrupt input of the central processing unit; a plurality of peripherals coupled with the central processing unit and the interrupt controller; wherein upon assertion of an interrupt by a peripheral of the microcontroller, the interrupt controller forwards an interrupt signal to the central processing unit and the central processing unit receives additional interrupt information from the peripheral that generated the interrupt, wherein the additional interrupt information or data derived from the additional interrupt information is stored in said register.
According to a further embodiment of the above microcontroller, after receiving an interrupt, the central processing unit may be configured to perform a context save before entering a service routine and the register may receive the additional interrupt information after said context save. According to a further embodiment of the above microcontroller, said additional information may be used to shift a constant value and wherein the shifted constant value is moved into the register. According to a further embodiment of the above microcontroller, said additional information can be an interrupt number which is directly stored in a working register of the CPU. According to a further embodiment of the above microcontroller, the microcontroller can be programmed to provide for an interrupt service routine that evaluates the content of the working register to branch to a respective service routine associated with an interrupt source that generated the interrupt.
According to various embodiments, a vectored interrupt system can be created that is compatible with an existing design of microcontrollers. The features discussed below are not limited to 8-bit microcontrollers but may also apply to 16-bit or 32-bit microcontrollers if such devices comprise an insufficient interrupt control architecture. According to various embodiments, an existing interrupt handling is maintained and a second mode of operation is provided. In the first operating mode, such a microcontroller having a single interrupt input may operate as originally designed, e.g. branch to the single pre-defined interrupt vector, e.g., address 0004h. In a second operating mode, the microcontroller may use a plurality of interrupt vectors associated with a single interrupt input.
Present existing designs of non-vectored microcontroller systems may be insufficient for an expanded number of peripherals which may be made possible by new core architecture designs. A vectored interrupt system may allow for integrating such peripherals with respect to individual interrupt functionality.
In particular, microcontrollers manufactured by the Assignee of the present application, such as microcontrollers from the PIC10/12/16 family all use a single interrupt vector at location 0004x in the program memory. The more advanced microcontrollers from the PIC 18 family use a dual priority vectored system.
Assignee's PIC16 family of microcontrollers does not provide for vectors. The more advanced PIC18 family does not have a software solution and does not have supervisory interrupt control. Moreover, the more advanced PIC18 family as well as the PIC 16 family need to trim latency in particular due to the sheer number of interrupt sources on some of the microcontrollers. The PIC16/18 family both have blocks to boot loader implementations.
The existing conventional PIC18 vectored interrupt system is expanded according to various embodiments with a base address register that allows the movement of the vector table to support boot loaders.
According to an embodiment, the latency time can be trimmed by removing return to main instructions, e.g., from a High interrupt transitioning to another pending High interrupt, a Low interrupt transitioning to another pending Low interrupt, and a High interrupt transitioning to a Low interrupt. In other words, a return from interrupt instruction can be removed and the system jumps directly to the next pending interrupt routine.
Context for both High and Low priority interrupts can be made accessible for RTOS support.
According to other embodiments, for systems that use high priority timer interrupts to watch dog low priority communication peripherals, the ability to clear interrupted low priority interrupts without using the global interrupt enable bit GIE is provided. According to various embodiments, a POP instruction may be added to the core if not already present to remove a respective return vector from the Low priority interrupt.
According to yet another embodiment, a context save for both Low and High priority interrupts are visible through context registers. Register space is conserved through the context control register that allow toggling between low and high access. The improved microcontrollers have the ability to clear low context on command to support watch dog functions.
The solution according to some embodiments, are backward compatible with legacy mode option to interrupt to location 0004x. The Mode is expanded by the addition of function that loads interrupt number into W register prior to branch to 0004x
According to some embodiments, such a dual mode vector interrupt may be implemented with 2 levels of priority that employs both a straight vector table and a vector number for software based systems.
Data memory 140 may be accessible through the system bus and program memory 150 may have its own bus. However, other designs may be chosen. Some of the peripherals 130a . . . n or all of them may generate an interrupt signal which is fed to an interrupt controller 120. The interrupt controller may generate a single interrupt signal which is fed to the respective input of the CPU 110.
A vectored system is shown in
A mode control register 170 can be provided that allows the interrupt controller and CPU to operate in a first mode (compatibility mode) in which only a single interrupt signal is generated and the software must poll the interrupt flags as shown in
According to one embodiment, the enhancement may further be used in a single interrupt mode which only uses the second mode as described above. This embodiment allows for a reduced hardware solution. According to this embodiment, the additional information is directly loaded into a register of the CPU, preferably a working register of the ALU. This solution provides for the flexibility of a vectored interrupt system without the requirement of hardware that must decode the information and automatically set the respective interrupt vector.
The state diagram in
According to other implementations of the two operating modes, as mentioned above, the vector does not need to be calculated by software within the interrupt service routine. While such a solution provides for backward compatibility, other architectures might allow a hardware calculation of the vector that is directly applied when the interrupt is received thereby allowing to directly jump to various vector addresses depending on the provided vector address.
The system is designed to work within 8-bit architecture, in particular those, designed by the Assignee of the present application. However, the proposed implementations may also apply to other 8-bit systems as well as 16-bit or 32-bit systems that use corresponding interrupt logic.
This application claims priority to commonly owned U.S. Provisional Patent Application No. 62/129,481 filed Mar. 6, 2015; which is hereby incorporated by reference herein for all purposes.
Number | Date | Country | |
---|---|---|---|
62129481 | Mar 2015 | US |