Method for communicating a reference time base in a microcontroller, and corresponding microcontroller integrated circuit.
A dual-frequency clock system for microcontrollers addresses the challenge of maintaining precise time reference across modes by using a low-frequency clock in standby and a high-frequency clock in active modes, ensuring rapid access and reducing latency issues.
Patent Information
- Application Number
- FR2021007062
- Authority / Receiving Office
- FR · FR
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2021-06-30
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-06-30
AI Technical Summary
Existing microcontroller systems face challenges in maintaining a precise system reference time during sleep and active modes due to the limitations of low-power and general-purpose hardware clocks, leading to reduced system responsiveness and potential loss of time reference during sleep modes.
A dual-frequency clock system is implemented, comprising a low-frequency clock for standby mode and a high-frequency clock for active mode, allowing rapid access and precise updating of the reference time base, with drift compensation to maintain accuracy across modes.
The dual-frequency clock system enables low-latency, precise access to the reference time base in both standby and active modes, enhancing system responsiveness and reducing the risk of time reference loss during sleep modes.
Smart Images

Figure 00000021_0000 
Figure 00000022_0000 
Figure 00000022_0001
Abstract
Description
Title of the invention: Method for communicating a reference time base in a microcontroller, and corresponding microcontroller integrated circuit.
[0001] Embodiments and implementations relate to integrated circuits, in particular microcontrollers and the communication of a reference time base for microcontroller operations.
[0002] Operating systems run by relatively simple application microcontrollers, for example an operating system of a microcontroller of a connected object, rely on hardware clocks to maintain a system reference time.
[0003] Hardware clocks are typically formed by a counter incremented, or updated, by the clock cycles of a clock signal.
[0004] Operating systems use this system reference time as a major component of their schedulers to maintain a complete list of software task execution times and precise times in task scheduling. Operating systems also frequently read the system reference time to adapt to it and compare it to a theoretical time.
[0005] As a result, there may be many accesses to the counter providing the reference time during the operating system software activities, which involve many (re)plannings, and therefore many read accesses to the counter and many write accesses to program interrupts in comparator registers.
[0006] It can be considered that there are typically two categories of hardware clocks, one called low-power, the other general-purpose. Low-power clocks are typically clocked by a clock signal at a low frequency, for example 32 kHz, and operate continuously, particularly during low-power modes, called "standby." General-purpose clocks are typically clocked by a clock signal at a high frequency, for example a few MHz, and operate in an active mode, and, in particular, do not operate during standby modes, the oscillator generating the high-frequency clock signal being deactivated to reduce current consumption.
[0007] Consequently, the use of the general purpose hardware clock allows quick access to the counter, but the hardware clock cannot be used in standby mode, so the time reference is lost when entering standby mode and the hardware clock cannot be used to program a system wake-up.
[0008] The general purpose hardware clock is therefore not conventionally used to provide the system reference time.
[0009] The low-power hardware clock can be used in standby mode and used to program a system wake-up, but access to the counter is slow because of the low frequency of the clock signal that drives it.
[0010] Indeed, it typically takes several clock cycles to program interrupts in a comparator register; for example, three 32 kHz clock cycles last about one hundred seconds. During this time, the central processing unit of the operating system, which operates at high speed (on the order of 100 MHz), sometimes tries to program a new value for the comparator, which is not possible.
[0011] Furthermore, operating system scheduling operations can occur in a critical section, i.e., when interrupts are disabled. Accessing the long time counter therefore increases the time spent in the critical section. System responsiveness is affected. In the worst-case scenario, events or data received from certain devices may be lost.
[0012] Moreover, the resolution of the counter is low because it is based on the low frequency, and therefore the programmed interruption time cannot be very precise.
[0013] Classically, to overcome these problems, very complex software solutions that consume computing resources are implemented and the communication rate with peripherals is limited below its capacity.
[0014] Therefore, there is a need to communicate a reference time base value that can both operate in standby mode and not present the problems of reduced system responsiveness, limitation of communication throughput, while avoiding complex software solutions.
[0015] In this regard, a high-speed, low-power hardware clock is proposed according to embodiments and implementations.
[0016] According to one aspect, a method is proposed for communicating a value of a reference time base contained in a counter register accessible by a microcontroller processing unit capable of operating in standby and active modes, comprising generating a so-called low-frequency clock signal having a first frequency, in standby and active modes, and generating a so-called high-frequency clock signal having a second frequency greater than the first frequency, in active mode, wherein the value of the reference time base is updated at each period of the low-frequency clock signal in standby mode, and access to the counter register is timed with the high-frequency clock signal in active mode.
[0017] For example, the first frequency is less than 1 MHz (megaHertz) or even in less than 100 kHz (kilohertz), and the second frequency is greater than 1 MHz. In practice, the first frequency can be between 32 kHz and 300 kHz (for example, a quartz crystal at 32.768 kHz), and the second frequency can be between 4 MHz and 500 MHz.
[0018] In other words, it is proposed to provide a time base that operates in both sleep and active modes, with low latency (fast) read and write access in active mode.
[0019] For example, the counter register may indeed include a read register accessible for reading by the processing unit and containing said value of the reference time base, as well as a compare register accessible for writing by the processing unit and containing a value of a programmed interrupt time.
[0020] According to one embodiment, the value of the reference time base is updated by an increment corresponding to the first frequency, at each period of the low frequency clock signal in standby mode, and is updated by an increment corresponding to the second frequency, at each period of the high frequency clock signal in active mode.
[0021] Thus, in addition to the fast access to the counter register in active mode, the value of the reference time base benefits from a finer resolution.
[0022] Advantageously, the value of the reference time base updated at each period of the high-frequency clock signal in the active mode is realigned with each period of the low-frequency clock signal, the realignment comprising either a jump to the next value equal to a multiple of the ratio of the second frequency to the first frequency at the end of said period of the low-frequency clock signal, or a stop at a value equal to a multiple of said ratio until the end of said period of the low-frequency clock signal.
[0023] In other words, this corresponds to a compensation of a possible drift between the first frequency of the low frequency clock signal and the second frequency of the high frequency clock signal, in a disciplined manner by the low frequency clock signal (i.e., the low frequency clock signal is taken as a reference to compensate for the drift).
[0024] According to another embodiment, the value of the reference time base of the counter register accessible by the processing unit is updated at each period of the low-frequency clock signal in the active mode.
[0025] In other words, in the active mode, the counter register is updated slowly at the first frequency, but is quickly accessible at the second frequency, in particular where appropriate by writing to the comparison register, due to the clocking of the counter register by the high-frequency clock signal.
[0026] Advantageously, a value of the reference time base contained by a The root counter register is updated at each period of the low-frequency clock signal in both standby and active modes, with the reference time base value of the counter register accessible by the processing unit being synchronized to the reference time base value of the root counter register at each period of the low-frequency clock signal in active mode.
[0027] In the present context, "root counter" means a counter which is not directly accessible by an external element (in particular by the processing unit), but which is used to generate a value intended to be copied (synchronized) into the counter register accessible by the processing unit.
[0028] In other words, a low-frequency hardware clock is duplicated in a high-frequency domain to allow fast access to the counter register. Synchronization corresponds, for example, to a copy of the values from one register to the other.
[0029] According to another embodiment, the counter register accessible by the processing unit contains high-order bits and low-order bits of the reference time base value, and it is the value of the high-order bits that is synchronized to the reference time base value of the root counter register at each period of the low-frequency clock signal in the active mode, the value of the low-order bits being updated at each period of the high-frequency clock signal in the active mode.
[0030] In other words, this corresponds to a hardware clock combining a slow hardware clock that is always available and a fast hardware clock that is available in the active mode.
[0031] Advantageously, the value of the least significant bits is realigned on each period of the low-frequency clock signal, the realignment comprising either a reset of the least significant bits at the end of said period of the low-frequency clock signal, or a blocking of the value of the least significant bits at a ceiling value equal to the ratio of the second frequency to the first frequency, until the end of said period of the low-frequency clock signal.
[0032] Advantageously, the value of the programmed interrupt time contained in the comparison register belonging to the counter register writable by the processing unit, is synchronized in a comparison register belonging to the root counter register before each transition from active mode to standby mode.
[0033] According to another aspect, a microcontroller integrated circuit capable of operating in standby and active modes is also proposed, comprising a processing unit and a time reference circuit having a counter register configured to hold a value of a reference time base and accessible by the processing unit, a first clock circuit configured to generate a so-called low-frequency clock signal having a first frequency, in the mode standby and in active mode, and a second clock circuit configured to generate a so-called high-frequency clock signal having a second frequency higher than the first frequency, in active mode, wherein the time reference circuit is configured to update the value of the reference time base at each period of the low-frequency clock signal in standby mode, and to time the access to the counter register with the high-frequency clock signal in active mode.
[0034] For example, the counter register may include a read register accessible for reading by the processing unit and containing said reference time base value, as well as a compare register accessible for writing by the processing unit and containing a value of a programmed interrupt time.
[0035] According to one embodiment, the time reference circuit includes a logic circuit configured to update the value of the reference time base by an increment corresponding to the first frequency, at each period of the low frequency clock signal in standby mode, and to update the value of the reference time base by an increment corresponding to the second frequency, at each period of the high frequency clock signal in active mode.
[0036] Advantageously, the time reference circuit further includes a drift compensation circuit configured to control the logic circuit so as to realign the value of the updated reference time base at each period of the high-frequency clock signal in the active mode, on each period of the low-frequency clock signal, the realignment comprising either a jump to the next value equal to a multiple of the ratio of the second frequency to the first frequency at the end of said period of the low-frequency clock signal, or a stop at a value equal to a multiple of said ratio until the end of said period of the low-frequency clock signal.
[0037] According to another embodiment, the time reference circuit is further configured to update the value of the reference time base of the counter register accessible by the processing unit at each period of the low-frequency clock signal in active mode.
[0038] Advantageously, the time reference circuit further includes a root counter register configured to contain a reference time base value updated at each period of the low-frequency clock signal in standby mode and in active mode, the time reference circuit being configured to synchronize the reference time base value of the counter register accessible by the processing unit with the reference time base value of the root counter register, at each period of the low-frequency clock signal, in active mode.
[0039] According to another embodiment, the counter register accessible by the processing unit is adapted to contain high-order bits and low-order bits of the reference time base value, the time reference circuit is configured to synchronize the value of said high-order bits with the value of the root counter register, at each period of the low-frequency clock signal, in the active mode, and to update the value of said low-order bits of the reference time base value at each period of the high-frequency clock signal in the active mode.
[0040] Advantageously, the counter register accessible by the processing unit is configured to realign the value of the least significant bits with the low-frequency clock signal, the realignment comprising either a reset of the least significant bits at the end of said period of the low-frequency clock signal, or a blocking of the value of the least significant bits at a ceiling value equal to the ratio of the second frequency to the first frequency, until the end of said period of the low-frequency clock signal.
[0041] Advantageously, the root counter register includes a comparison register, the time reference circuit being configured to synchronize a value of a programmed standby interrupt time in the comparison register of the root counter register, with the value of the programmed interrupt time contained in the comparison register belonging to the counter register writable by the processing unit, before each transition from active mode to standby mode.
[0042] Other advantages and features of the invention will become apparent upon examination of the detailed description of embodiments and implementations, which are by no means limiting, and the accompanying drawings, in which:
[0043] [Fig.l] ;
[0044] [Fig.2] ;
[0045] [Fig.3] ;
[0046] [Fig.4] ;
[0047] [Fig.5] ;
[0048] [Fig.6] ;
[0049] [Fig.7] illustrate embodiments and implementations of the invention.
[0050] Fig. 1 illustrates a microcontroller MCU made in an integrated manner in an integrated circuit, and for example intended to economically equip a simple APP device, of the connected object type (“loT” for “Internet of Things” in English).
[0051] Indeed, the microcontrollers (MCUs) of connected objects, such as audio devices, home automation systems, or household appliances, implement operating systems with relatively simple functions, particularly compared to microcontrollers of computers or multifunction phones. The functions implemented in connected objects are usually the control and management of PRPHl-PRPHn peripherals of the APP device, typically wireless communication peripherals, or even a display, and peripherals specific to the primary purpose of the object.
[0052] Furthermore, in connected objects, the energy consumption of MCU microcontrollers is typically constrained to economy.
[0053] The MCU microcontroller includes a CPU processing unit, adapted to implement software operations, in particular the operating system.
[0054] The processing unit's operations can be clocked by an internal clock signal having a frequency on the order of one hundred MHz (megahertz), and generates output and control signals at frequencies that can be on the order of 10 MHz or higher. That being said, the frequencies of the output and control signals are adapted to the communications with the peripherals to which the signals are transmitted, and can be on the order of tens of kHz for input / output, hundreds of kHz for asynchronous serial links (for example, a "UART" link for "Universal Asynchronous Receiver Transmitter"), and tens of MHz for high-speed serial links (for example, an "SPI" link for "Serial Peripheral Interface").
[0055] The MCU microcontroller can operate in standby mode (VEI) and in active mode (ACT), and in this respect a VEI domain relating to standby mode, which can be called "standby domain" or "always on domain" and an ACT domain relating to active mode, which can be called "run domain".
[0056] The VEI standby domain includes a first LPTIM clock circuit, configured to generate a first "low-frequency" clock signal LPclk, having a first frequency. The first LPTIM clock circuit is configured to generate the low-frequency LPclk clock signal in both standby and active modes of the microcontroller MCU. The first LPTIM clock circuit is specifically optimized for low power consumption and can serve as a stable time reference for the system.
[0057] For example, the first frequency is on the order of kHz (kiloHertz), for example 32kHz.
[0058] The active domain ACT includes a second clock circuit HSTIM configured to generate a second, so-called "high-frequency" clock signal HSclk, having a second frequency higher than the first frequency. The second clock circuit LPTIM is configured to generate the high-frequency clock signal HSclk in active mode. The second clock circuit HSTIM consumes more power than the The first LPTIM clock circuit is notably disabled in standby mode.
[0059] For example, the second frequency is on the order of MHz (megaHertz), for example 10MHz or more.
[0060] The microcontroller includes a time reference circuit TMPref comprising a counter register RCNT configured to hold a value from a reference time base. The counter register RCNT is accessible by the CPU, for example via a BSYS system bus adapted for internal communication of the MCU integrated circuit.
[0061] Indeed, the operating system from a software point of view, or the processing unit from a hardware point of view, uses the reference time base to plan its activity, that is to say to maintain the complete list of execution times of software application tasks and the precise times of task planning, and also to adapt to the reference time base and compare it to a theoretical time.
[0062] The time reference circuit TMPref is configured to update the value of the reference time base contained in the counter register RCNT with the low frequency clock signal LPclk in standby mode, and to time access to the counter register RCNT with the high frequency clock signal HSclk in active mode.
[0063] A clear distinction must be made between the timing of access to the RCNT counter register, that is, the frequency at which the data contained in the register is refreshed, and the updating of the value contained in the register, that is, the incrementing of the value of the time base controlled at a given frequency. The term "increment" here means the increase of said value by an amount corresponding to the passage of time of one period at said given frequency, which is therefore not necessarily a unit value of a unit of time measurement.
[0064] Furthermore, in VEI standby mode, the CPU processing unit is inactive and, in particular, does not access the RCNT counter register. Consequently, the timing of access to the RCNT counter register during VEI standby mode does not need to be functionally developed, but it could nevertheless be considered that it would be done, like the updating of the contained value, by the low-frequency clock signal LPclk.
[0065] Thus, the RCNT counter register is not only updated and active in standby mode, which notably allows a programmed interrupt to be generated to "wake up" the MCU microcontroller from standby mode to active mode, but is also clocked by the high-frequency clock signal in active mode, which allows fast access with low latency to the RCNT counter register.
[0066] For example, as illustrated below in relation to Figures 2, 4 and 6, the counter register RCNT includes a read register CNT (Figures 2, 4, 6) accessible for reading by the CPU processing unit and containing said value of the reference time base, as well as a compare register CMP (Figures 2, 4, 6) accessible for writing by the CPU processing unit and containing a value of a programmed interrupt time.
[0067] The CMP comparison register is thus intended to contain the value of an instant, compared to the current value of the reference time base, making it possible to generate an interrupt when the value of the reference time base reaches or exceeds the value contained in the CMP comparison register.
[0068] The interruption can, for example, be an interruption of waking from sleep mode to active mode, or the starting of one or more processes (in a multitasking context), or the signaling of an elapsed time (“timeout” in English).
[0069] Finally, the update of the reference time base value contained in the RCNT counter register can be updated in different ways, in particular by the low frequency clock signal LPclk in standby mode, and especially by the high frequency clock signal HSclk or the low frequency clock signal LPslk in active mode.
[0070] Examples of realization and implementation, in particular for timing and updating the value of the reference time base contained in the RCNT counter register, are described below in relation to Figures 2 to 7.
[0071] [Fig.2] illustrates an example of an embodiment of the time reference circuit TMPref as described above in relation to [Fig.1].
[0072] In this example, the time reference circuit TMPref-2 includes, on the one hand, an SWT switching circuit configured to select either the low-frequency clock signal LPclk in standby mode or the high-frequency clock signal HSclk in active mode. The selected clock signal is transmitted as the useful clock signal CLK.
[0073] To select the LPclk or HSclk clock signal according to the operating mode of the microcontroller (MCU), the SWT switching circuit can be controlled by a hardware control signal (PRGhw) or a software control signal (PRGsw). The hardware control signal (PRGhw) is, for example, generated by the MCU itself to communicate its sleep or active operating mode. The software control signal (PRGsw) is, for example, generated by the operating system and can typically be written to a configuration register (CFG) belonging to a register bank (REG) of the time reference circuit (TMPref).
[0074] The useful clock signal CLK is distributed on the one hand to the counter register RCNT, to time the access to said counter register RCNT, that is to say the read access of the read register CNT, and the write access of the comparison register CMP.
[0075] The useful clock signal CLK is distributed on the other hand to an LGQ logic circuit configured to update the value of the reference time base by an increment corresponding to the frequency of the useful clock signal CLK, in a manner clocked by the useful clock signal CLK.
[0076] In detail, the logic circuit LGQ is thus configured to update the value of the reference time base by an increment corresponding to the duration of the period (i.e. the inverse of the frequency) of the low frequency clock signal LPclk, at each period of the low frequency clock signal LPclk in standby mode; and to update the value of the reference time base by an increment corresponding to the duration of the period of the high frequency clock signal HSclk, at each period of the high frequency clock signal HSclk in active mode.
[0077] Advantageously, the TMPref-2 time reference circuit may further include a CPSDR drift compensation circuit configured to realign the value of the reference time base CNTval ([Fig.3]), updated at each period of the high-frequency clock signal HSclk in active mode.
[0078] The drift compensation circuit CPSDR receives as input the low frequency clock signal LPclk and the high frequency clock signal HSclk, and generates an output signal adapted to control the logic circuit LGQ in order to achieve realignment.
[0079] Reference is made in this regard to [Fig.3].
[0080] Fig. 3 illustrates the evolution of the value of the reference time base CNTval, with respect to real time T, and as a function of possible drifts of the second frequency (i.e. the frequency of the high-frequency clock signal HSclk), and of the realignment process 320, 330.
[0081] The realignment process, implemented by the drift compensation circuit CPSDR, is disciplined by the low frequency clock signal LPclk, i.e. it is assumed that the low frequency clock signal LPclk does not drift, the latter serving as a reference if the second frequency HSclk tends to drift.
[0082] The drift compensation circuit CPSDR is configured for example to count the number of periods of the high frequency clock signal HSclk during one period of the low frequency clock signal LPclk.
[0083] If the number of periods counted is equal to the expected value of the ratio of the second frequency (i.e., the frequency of the high-frequency clock signal HSclk) to the second frequency (i.e., the frequency of the low-frequency clock signal LPclk), then the high-frequency clock signal has not drifted (310). If the number of If the number of counted periods is greater than the expected value of the ratio of the second frequency to the first frequency, then the high-frequency clock signal is too fast (320). Conversely, if the number of counted periods is less than the expected value of the ratio of the second frequency to the second frequency, then the high-frequency clock signal is too slow (330).
[0084] For example, if the first frequency LPclk is 32kHz, and the second frequency HSclk is 32MHz, the ratio of the second frequency to the first frequency is 1000, and the value of the reference time base CNTval is incremented by 1 at each period of the high-frequency clock signal HSclk.
[0085] At the next period of the low-frequency clock signal LPclk, the value of the reference time base CNTval is realigned to a value modulo the said frequency ratio (i.e., 1000). By "a value modulo the ratio," we mean "a zero value modulo the ratio," which means "a value equal to an integer multiple of the ratio." The values modulo the said ratio are represented by the dashed curve.
[0086] Thus, when the high-frequency clock signal HSclk is too slow, then the value CNTval jumps 330 ([Fig.3]) to the next modulo value; and when the high-frequency clock signal HSclk is too fast, the value CNTval stops 320 ([Fig.3]) at the modulo value.
[0087] Thus, the value of the reference time base CNTval is incremented modulo 1000 by the realignment process, at each period of the low voltage clock signal LPclk.
[0088] [Fig.4] illustrates an example of an embodiment of the time reference circuit TMPref as described above in relation to [Fig.1].
[0089] In this example, the TMPref-4 time reference circuit is configured to update the value of the reference time base, contained in the RCNT counter register, at each period of the LPclk low-frequency clock signal in standby mode and in active mode, while access to the RCNT counter register is clocked with the HSclk high-frequency clock signal in active mode.
[0090] In this respect, the TMPref-4 time reference circuit comprises, on the one hand, a high-frequency register bank HSREG, including the counter register RCNT, whose access is clocked by the high-frequency clock signal HSclk in active mode. And, on the other hand, the TMPref-4 time reference circuit comprises a low-frequency register bank LPREG, including a root counter register RCNTR, which is updated and clocked by the low-frequency clock signal LPclk in active and standby modes.
[0091] The RCNT counter register of the HSREG high-frequency register bank includes, as described above, an HSCNT read register and is intended to contain said reference time base value, as well as an HSCMP comparison register containing a value of a programmed interrupt time, respectively readable and writable by the CPU processing unit.
[0092] The high-frequency register bank HSREG further contains a configuration register that can contain a software command PRGsw, allowing communication of the active or standby state of the microcontroller MCU. A hardware command PRGhw as described previously in relation to [Fig. 2] can be considered.
[0093] The root counter register RCNTR of the low-frequency register bank LPREG analogously includes a read register LPCNT configured to hold a root value of the reference time base, updated at each period of the low-frequency clock signal LPclk, and a compare register CMP intended to hold a value of a programmed interrupt time.
[0094] The value of the reference time base of the RCNT counter register accessible by the processing unit in active mode, is synchronized with a sync_cnt synchronization signal on the root value contained in the LPCNT read register of the root counter register RCNTR, in standby mode and in active mode.
[0095] The value of the programmed interrupt time contained in the LPCMP comparator register of the root counter register RCNTR, is synchronized with a sync_cmp synchronization signal on the value of the HSCMP comparator register of the counter register RCNT, in particular in active mode.
[0096] Fig. 5 illustrates a flowchart of the operation of the sync_cnt, sync_cmp synchronizations between the values contained in the counter register RCNT and the root counter register RCNTR.
[0097] In standby mode, accesses to the root read register LPCNT and the root compare register LPCMP are on the one hand timed by the low frequency clock signal LPclk, and on the other hand, the root value contained by the root read register LPCNT is updated "act" at each period of the low frequency clock signal LPclk.
[0098] At each period of the low-frequency clock signal LPclk, the root value (LPCNT) is compared to the interrupt-time value (LPCMP), and an intrpt_vei interrupt is generated when these values are equal. In standby mode, the intrpt_vei interrupt is typically a wake-up interrupt for a microcontroller (MCU) transition to active mode.
[0099] In active mode, the high-frequency clock signal HSclk is available and allows access to the read register HSCNT and the compare register HSCMP to be clocked, while the root read register LPCNT is always clocked and updated "act" by the low-frequency clock signal LPclk.
[0100] The value of the reference time base of the high-frequency read register HSCNT, accessible by the CPU processing unit, is synchronized sync_cnt to the value of the root counter register RCNTR, for example at each period of the low-frequency clock signal.
[0101] The interrupt time value of the high-frequency comparator register HSCMP can be written (or programmed) by the CPU_wrt processing unit at the clock speed by the high-frequency clock signal HSclk.
[0102] Programming a new interrupt time value can, for example, last a few periods, for example three periods, of the clock signal timing the access to the HSCMP comparison register.
[0103] The interrupt generation mechanism intrpt_act in the active mode is implemented in an analogous manner, by comparing the value contained in the comparison register HSCMP with the current value of the read register HSCNT, at each period of the high-frequency clock signal HSclk.
[0104] Consequently, the CPU processing unit can quickly schedule useful intrpt_act interrupts in active mode, for example for software applications, without being constrained by the latency of writes to the HSCMP comparison register.
[0105] On the other hand, the interrupt time value of the low-frequency comparator register LPCMP is synchronized sync_cmp to the value of the high-frequency comparator register HSCMP, in particular when entering standby mode.
[0106] Synchronization processes exist between domains clocked at different frequencies, making it possible to avoid conflicts if the synchronized value in the high-frequency domain changes during the slower transfer to the low-frequency domain. This is advantageous for synchronizing the values of the interrupt instant `sync_cmp`, since synchronization occurs from the high-frequency domain to the low-frequency domain, and the synchronized value can be modified from the high-frequency domain. However, synchronizing the values of the reference time base `sync_cnt` does not encounter the conflict problem caused by a change during the transfer, since synchronization occurs from the low-frequency domain to the high-frequency domain, and the synchronized value is not modified from the high-frequency domain.
[0107] [Fig.6] illustrates another example of an embodiment of the TMPref time reference circuit as described above in relation to [Fig.1], which can be seen as a variant of the example described in relation to Figures 4 and 5. The common elements support the same references and will not all be detailed again.
[0108] Fig. 7 illustrates a flowchart of the operation of the synchronizations between the counter register RCNT and the root counter register RCNTR of this variant.
[0109] In this variant, the HSCNT read register (belonging to the register of RCNT counter located in the high-frequency register bank HSREG) features a functional separation between the most significant bits HSCNT_msb and the least significant bits HSCNT_lsb of the reference time base value.
[0110] The TMPref-6 time reference circuit is configured to update the value of the most significant bits HSCNT_msb at each period of the low-frequency clock signal LPclk in standby mode and in active mode.
[0111] The updating of the most significant bits HSCNT_msb is done in the same way as described above in relation to Figures 4 and 5, that is to say by the sync_cnt synchronization mechanism on the root value of the root read register LPCNT which is clocked and updated "act" by the low frequency clock signal LPclk.
[0112] The TMPref-6 time reference circuit is configured in parallel to update "act" the value of the least significant bits HSCNT_lsb at each period of the high-frequency clock signal HSclk in active mode.
[0113] For example, the high-frequency counter register RCNT can be constructed to contain words or data (i.e., the values contained in the read register HSCNT_msb, HSCNT_lsb and in the compare register HSCMP) having a larger size than the words or data contained in the root counter register RCNTR.
[0114] For example, the values in the high-frequency counter register RCNT can be 64-bit encoded, with 32 most significant bits HSCNT_msb and 32 least significant bits HSCNT_lsb, while the values in the root counter register RCNTR can be 32-bit encoded. A consistency mechanism between the most significant bits HSCNT_msb and the least significant bits HSCNT_lsb may be provided. Similarly, a 64-bit to 32-bit conversion mechanism (sync_cmp) may be provided for the synchronization (sync_cmp) of the interrupt-time value from the comparator register HSCMP to the comparator register LPCMP. In practice, the conversion mechanism (sync_cmp) may simply include a copy of the most significant bits from the HSCMP register to the LPCMP register.
[0115] Alternatively, the values contained in the high-frequency counter register RCNT can be encoded on 32 bits, with a distribution of, for example, 24 most significant bits HSCNT_msb and 8 least significant bits HSCNT_lsb, or 28 most significant bits HSCNT_msb and 4 least significant bits HSCNT_lsb, for values contained in the root counter register RCNTR encoded on 32 bits. A 32-bit to 24-bit or 28-bit conversion mechanism can also be provided for the sync_cnt synchronization of the reference time base value of the read register HSCNT, based on the root value of the root read register LPCNT.
[0116] The distribution can advantageously allow for modulating a compromise between the dynamics of the most significant bits HSCNT_msb, which tends to be as large as possible, and the precision of the least significant bits HSCNT_lsb, for which the microsecond may be sufficient and the nanosecond superfluous, depending on the needs of the software applications.
[0117] The distribution of the most significant bits HSCNT_msb and the least significant bits HSCNT_lsb can advantageously be programmed during use, according to a specification of the needs of the software applications being executed.
[0118] Finally, in this variant, a realignment mechanism for the value of the least significant bits HSCNT_lsb on the low-frequency clock signal LPclk similar to the realignment described previously in relation to [Fig.3] can be implemented directly by the counter register RCNT.
[0119] Indeed, the counter register RCNT can be configured to implement said realignment, either by resetting the least significant bits HSCNT_lsb at the end of said period of the low-frequency clock signal LPclk, or by blocking the value of the least significant bits HSCNT_lsb at a ceiling value equal to the ratio of the second frequency (i.e. the frequency of the high-frequency clock signal HSclk) to the first frequency (i.e. the frequency of the low-frequency clock signal LPclk), until the end of said period of the low-frequency clock signal LPclk.
[0120] This corresponds to a finite-stroke (usually "single-shot" in English, as opposed to "free-running") operation of the RCNT counter register, which is reset at each period of the low-frequency clock signal LPclk. In other words, the RCNT counter register is configured to stop when it reaches a ceiling value (equal to the ratio between the frequencies, 1000 in the example given previously in relation to Figures 2 and 3) and to restart at 0 at each period of the low-frequency clock signal LPclk. The CPU processing unit can periodically update the ceiling value to minimize error and compensate for drift.
[0121] In summary, a technique for generating and communicating the microcontroller's reference time base value in a continuously operating counter register with low-latency access for reading and programming in active mode has been described. The reference time base value may benefit from drift compensation and a mode transition mechanism that may be automatic or programmable. In exemplary embodiments, the counter register may be obtained by means of a duplicated counter in the high-frequency domain, or a counter in the high-frequency domain based on a combination of a high-frequency updated counter in active mode and an always-available counter updated at a lower frequency.
Claims
Claims
1. Method for communicating a value of a reference time base contained in a counter register (RCNT) accessible by a microcontroller (MCU) processing unit (CPU) capable of operating in sleep mode (VEI) and in active mode (ACT), comprising a generation of a so-called low-frequency clock signal (LPclk) having a first frequency, in the sleep mode and in the active mode, and a generation of a so-called high-frequency clock signal (HSclk) having a second frequency higher than the first frequency, in the active mode, in which the value of the reference time base is updated at each period of the low-frequency clock signal (LPclk) in the sleep mode (VEI), and the access to the counter register (RCNT) is clocked with the high-frequency clock signal (HSclk) in the active mode;characterized in that the counter register (RCNT) includes a read register (CNT) accessible in reading by the processing unit (CPU) and containing said value of the reference time base, as well as a comparison register (CMP) accessible in writing by the processing unit (CPU) and containing a value of a programmed interrupt time, and in that the value of the programmed interrupt time contained in the comparison register (CMP) belonging to the counter register (RCNT) accessible in writing by the processing unit (CPU), is synchronized (sync_cmp) in a comparison register (LPCMP) belonging to a root counter register (RCNTR) before each transition from the active mode (ACT) to the standby mode (VEI), the root counter register (RCNTR) being updated at each period of the low-frequency clock signal (LPclk) in the standby mode and in the active mode.;
2. Method according to claim 1, in which the value of the reference time base (CNT) is updated by an increment corresponding to the first frequency, at each period of the low frequency clock signal (LPclk) in the standby mode, and is updated by an increment corresponding to the second frequency, at each period of the high frequency clock signal (HSclk) in the active mode.
3. A method according to claim 2, wherein the value of the reference time base updated at each period of the clock signal high frequency (HSclk) in the active mode is realigned to each period of the low frequency clock signal (LPclk), the realignment comprising either a jump (330) to the next value equal to a multiple of the ratio of the second frequency (HSclk) to the first frequency (LSclk) at the end of said period of the low frequency clock signal (LPclk), or a stop (320) on a value equal to a multiple of said ratio until the end of said period of the low frequency clock signal (LPclk).
4. Method according to claim 1, in which the value of the reference time base (HSCNT; HSCNT_msb) of the counter register accessible by the processing unit (RCNT) is updated at each period of the low frequency clock signal (LPclk) in the active mode.
5. Method according to claim 4, in which a value of the reference time base (LPCNT) contained by the root counter register (RCNTR) is updated at each period of the low frequency clock signal (LPclk) in the standby mode and in the active mode, the value of the reference time base (HSCNT) of the counter register accessible by the processing unit (RCNT) being synchronized (sync_cnt) on the value of the reference time base (LPCNT) of the root counter register (RCNTR), at each period of the low frequency clock signal (LPclk), in the active mode.
6. Method according to claim 5, in which the counter register accessible by the processing unit (RCNT) contains high-order bits (HSCNT_msb) and low-order bits (HSCNT_msb) of the value of the reference time base, and in which it is the value of the high-order bits (HSCNT_msb) which is synchronized to the value of the reference time base (LPCNT) of the root counter register (RCNTR) at each period of the low-frequency clock signal (LPclk) in the active mode, the value of the low-order bits (HSCNT_lsb) being updated at each period of the high-frequency clock signal (HSclk) in the active mode.
7. The method of claim 6, wherein the value of the least significant bits (HSCNT_lsb) is realigned to each period of the low frequency clock signal (LPclk), the realignment comprising either resetting the least significant bits (HSCNT_lsb) at the end of said period of the low frequency clock signal (LPclk), or clamping the value of the least significant bits (HSCNT_lsb) to a ceiling value equal to the ratio of the second frequency (HSclk) to the first frequency (LPclk), until the end of said period of the low frequency clock signal (LPclk).
8. Microcontroller integrated circuit (MCU) capable of operating in sleep mode (VEI) and in active mode (ACT), comprising a processing unit (CPU), and a time reference circuit (TMPref) comprising a counter register (RCNT) configured to contain a value of a reference time base and accessible by the processing unit (CPU), a first clock circuit (LPTIM) configured to generate a so-called low-frequency clock signal (LPclk) having a first frequency, in sleep mode and in active mode, and a second clock circuit (HSTIM) configured to generate a so-called high-frequency clock signal (HSclk) having a second frequency higher than the first frequency, in active mode, in which the time reference circuit (TMPref) is configured to update the value of the reference time base at each period of the low-frequency clock signal (LPclk) in sleep mode (VEI),and to clock access to the counter register (RCNT) with the high-frequency clock signal (HSclk) in the active mode (ACT); characterized in that the counter register (RCNT) includes a read register (CNT) accessible in reading by the processing unit (CPU) and containing said value of the reference time base, as well as a comparison register (CMP) accessible in writing by the processing unit (CPU) and containing a value of a programmed interrupt instant, and in that the time reference circuit (TMPref-4; TMPref-6), further comprising a root counter register (RCNTR) configured to be updated at each period of the low-frequency clock signal (LPclk) in the standby mode and in the active mode and comprising a comparison register (LPCMP),is configured to synchronize (sync_cmp) a value of a sleep mode scheduled interrupt time (LPCMP) in the comparison register (LPCMP) of the root counter register (RCNTR), to the value of the scheduled interrupt time contained in the comparison register (CMP) belonging to the counter register (RCNT) accessible in writing by the processing unit (CPU), before each transition from active mode (ACT) to sleep mode (VEI).,
9. Integrated circuit according to claim 8, in which the time reference circuit (TMPref-2) comprises a logic circuit (LGQ) configured to update the value of the reference time base by an increment corresponding to the first frequency, at each period of the low frequency clock signal (LPclk) in the sleep mode, and to update the value of the reference time base by an increment corresponding to the second frequency, at each period of the high frequency clock signal (HSclk) in the active mode.
10. Integrated circuit according to claim 9, wherein the time reference circuit (TMPref-2) further comprises a drift compensation circuit (CPSDR) configured to control the logic circuit (LGQ) so as to realign the value of the reference time base (CNTval) updated at each period of the high frequency clock signal (HSclk) in the active mode, on each period of the low frequency clock signal (LPclk), the realignment comprising either a jump (330) to the next value equal to a multiple of the ratio of the second frequency (HSclk) to the first frequency (LPclk) at the end of said period of the low frequency clock signal (LPclk), or a stop (320) on a value equal to a multiple of said ratio until the end of said period of the low frequency clock signal (LPclk).
11. Integrated circuit according to claim 8, wherein the time reference circuit (TMPref-4; TMPref-6) is further configured to update the value of the reference time base (HSCNT; HSCNT_msb) of the counter register accessible by the processing unit (RCNT) at each period of the low frequency clock signal (LPclk) in the active mode.
12. Integrated circuit according to claim 11, wherein the root counter register (RCNTR) is configured to contain a value of the reference time base (LPCNT) updated at each period of the low frequency clock signal (LPclk) in the standby mode and in the active mode, the time reference circuit (TMPref-4; TMPref-6) being configured to synchronize (sync_cnt) the value of the reference time base (HSCNT) of the counter register accessible by the processing unit (RCNT) on the value of the reference time base (LPCNT) of the root counter register (RCNTR), at each period of the low frequency clock signal (LPclk), in the active mode.
13. Integrated circuit according to claim 12, in which the counter register accessible by the processing unit (RCNT) is adapted to contain high-order bits (HSCNT_msb) and low-order bits (HSCNT_lsb) of the value of the reference time base, and in wherein the time reference circuit (TMPref-6) is configured to synchronize (sync_cnt) the value of said high-order bits (HSCNT_msb) to the value of the root counter register (RCNTR), at each period of the low-frequency clock signal (LPclk) in the active mode, and to update the value of said low-order bits (HSCNT_lsb) with the value of the reference time base at each period of the high-frequency clock signal (HSclk) in the active mode.
14. Integrated circuit according to claim 13, wherein the counter register accessible by the processing unit (RCNT) is configured to realign the value of the least significant bits (HSCNT_lsb) to the low frequency clock signal (LPclk), the realignment comprising either a reset of the least significant bits (HSCNT_lsb) at the end of said period of the low frequency clock signal (LPclk), or a blocking of the value of the least significant bits (HSCNT_lsb) at a ceiling value equal to the ratio of the second frequency (HSclk) to the first frequency (LPclk), until the end of said period of the low frequency clock signal (LPclk).
