Microcontroller, external device, microcontrol system and method of communication
By defining virtual registers and generating configuration information within the microcontroller's address space, the problem of the MCU system's inability to monitor external devices is solved, enabling effective control of external devices in the absence of peripheral control modules and improving the flexibility of the simulation process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-14
- Publication Date
- 2026-03-31
AI Technical Summary
Existing MCU systems, lacking external device control modules, cannot monitor the status of external devices, resulting in reduced communication flexibility during digital circuit simulation.
By defining virtual registers within the microcontroller's address space, generating virtual register configuration information, and sending it to external devices, the external devices can execute corresponding operation commands, thereby enabling the monitoring and control of external devices.
Even in the absence of peripheral control modules, microcontrollers can effectively monitor and control external devices, improving the flexibility of digital circuit simulation.
Smart Images

Figure CN115729862B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology. More specifically, this invention relates to microcontrollers, external devices, microcontroller systems, and methods of communication. Background Technology
[0002] In many scenarios of digital circuit design simulation, a microcontroller unit (MCU) is required. Currently, most MCU debugging is achieved by compiling C / C++ code into machine language (assembly) that the MCU can recognize. In a typical simulation process, the C program is compiled to generate a hexadecimal file, which is read from the read-only memory (ROM) mapped in the MCU's address space. The MCU then fetches instructions from the ROM and begins execution.
[0003] However, current MCU systems, consisting of MCUs and their associated external devices (hereinafter referred to as MCU systems), hinder the simulation of digital circuit systems and reduce the flexibility of internal communication. This is because, in simulation, the MCU system simply executes instructions stored in ROM. Without an external device control module, the MCU cannot monitor the status of external devices, thus causing inconvenience in simulation. Summary of the Invention
[0004] One object of the embodiments of the present invention is to solve the above-mentioned problems and to provide advantages that will be described later.
[0005] Another objective of this invention is to provide a method for communicating a microcontroller, an external device, a microcontroller system, and a communication mechanism, so that the microcontroller can monitor external devices even when it lacks an external control module.
[0006] In a first aspect, embodiments of this application provide a method for a microcontroller to communicate with an external device, comprising:
[0007] The microcontroller receives access signals to its virtual registers;
[0008] The microcontroller generates corresponding virtual register configuration information based on the access signal; wherein, the virtual register configuration information includes address information and enable signal information for accessing the virtual register; the address information includes the address value of the access signal;
[0009] The external device detects the microcontroller to obtain the virtual register configuration information;
[0010] The microcontroller outputs the virtual register configuration information to the external device based on the detection signal from the external device.
[0011] The external device determines whether the enable signal contained in the enable signal information is valid;
[0012] When the enable signal is valid, the external device obtains the operation command corresponding to the access signal based on the address information;
[0013] The external device executes the operation command.
[0014] In some technical solutions, when the enable signal is valid, the external device obtains the operation instruction corresponding to the access signal based on the address information; including:
[0015] The external device assigns a specified value to the physical register used to transmit command information according to the address information; the physical register is a register that has a mapping relationship with the virtual register;
[0016] The external device obtains the operation command based on the specified value.
[0017] In some technical solutions, when the physical register is assigned a first specified value, the operation command is to assign a value to a specific register in the external device; when the physical register is assigned a second specified value, the operation command is to reset the external device.
[0018] In a second aspect, embodiments of this application provide a method for a microcontroller to communicate with an external device, comprising:
[0019] The microcontroller outputs virtual register configuration information to the external device based on the detection signal from the external device, so that the external device can execute operation commands;
[0020] The virtual register configuration information is generated by the microcontroller based on the access signal of its virtual register. The virtual register configuration information includes address information and enable signal information for accessing the virtual register. The address information includes the address value of the access signal, and the operation command is the command corresponding to the access signal.
[0021] In a third aspect, embodiments of this application provide a method for a microcontroller to communicate with an external device, comprising:
[0022] The external device detects the microcontroller to obtain virtual register configuration information and executes operation commands based on the virtual register configuration information;
[0023] The virtual register configuration information is generated by the microcontroller based on the access signal of its virtual register. The virtual register configuration information includes address information and enable signal information for accessing the virtual register. The address information includes the address value of the access signal, and the operation command is the command corresponding to the access signal.
[0024] In some technical solutions, the external device detects that the microcontroller has acquired virtual register configuration information and executes operation commands based on the virtual register configuration information, including:
[0025] The external device detects whether the microcontroller generates the virtual register configuration information;
[0026] The external device determines whether the enable signal contained in the enable signal information is valid;
[0027] When the enable signal is valid, the external device obtains the operation command based on the address information;
[0028] The external device executes the operation command.
[0029] In some technical solutions, when the enable signal is valid, the external device obtains the operation command based on the address information; including:
[0030] The external device assigns a specified value to the physical register used to transmit command information according to the address information; the physical register is a register that has a mapping relationship with the virtual register;
[0031] The external device obtains the operation command based on the specified value.
[0032] In a fourth aspect, embodiments of this application provide a microcontroller, including: a processor and a memory, wherein the memory stores a computer instruction program executable on the processor, and the computer instruction program, when executed by the processor, implements the steps of the method for the microcontroller to communicate with an external device as described in the second aspect.
[0033] In a fifth aspect, this application provides an external device for a microcontroller, comprising: a processor and a memory, wherein the memory stores a computer instruction program executable on the processor, and the computer instruction program, when executed by the processor, implements the steps of the method for communicating between a microcontroller and an external device as described in the third aspect embodiment.
[0034] In a sixth aspect, embodiments of this application provide a microcontroller system, including:
[0035] The microcontroller described in the fourth aspect; and
[0036] The external device described in the fifth aspect.
[0037] The embodiments of the present invention include the following beneficial effects:
[0038] In this embodiment, the microcontroller (MCU) generates register configuration information based on the access signal to the virtual register and sends it to the external device, enabling the external device to execute the operation command corresponding to the access signal, thereby achieving the purpose of controlling the external device. In other words, the microcontroller transmits the operation command information carried by the access signal to the external device through the virtual register, thus enabling the microcontroller to control external devices even in the absence of a peripheral control module.
[0039] Other advantages, objectives and features of the present invention will become apparent in part from the following description, and in part from those skilled in the art through study and practice of the invention. Attached Figure Description
[0040] Figure 1 This is a flowchart illustrating a method for communication between a microcontroller and an external device according to an embodiment of the present invention.
[0041] Figure 2 This is another flowchart illustrating the method for communication between a microcontroller and an external device according to an embodiment of the present invention;
[0042] Figure 3 This is a schematic diagram illustrating the working principle of a method for communication between a microcontroller and an external device according to an embodiment of the present invention.
[0043] Figure 4 This is another flowchart illustrating the method for communication between a microcontroller and an external device according to an embodiment of the present invention;
[0044] Figure 5 This is another flowchart illustrating a method for communication between a microcontroller and an external device according to an embodiment of the present invention. Detailed Implementation
[0045] The present invention will now be described in further detail with reference to the accompanying drawings, so that those skilled in the art can implement it based on the description.
[0046] The terms "comprising" and "including," and any variations thereof, used in the embodiments of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices. The terms "first," "second," etc., used in the embodiments of this application are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features.
[0047] In addition to the above, it should be emphasized that the reference to "embodiment" herein means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0048] <First aspect of this application>
[0049] like Figure 1 As shown, a first aspect of this application provides a method for a microcontroller to communicate with an external device, including the following steps S101 to S107:
[0050] S101, the microcontroller receives an access signal to its virtual register; the virtual register is defined within the microcontroller's address space. It should be noted that the virtual register can be defined and generated within the address space by a C program, for example, by writing a file that generates the virtual register into the address space. The access signal can be issued by a C program module. Specifically, if the virtual register is accessed in the C program during simulation, the microcontroller will access the address space based on the access signal to further access the virtual register.
[0051] S102. The microcontroller generates corresponding virtual register configuration information based on the access signal; wherein, the virtual register configuration information includes address information and enable signal information for accessing the address space; the address information includes the address value of the access signal. S103. The external device detects the microcontroller to obtain the virtual register configuration information.
[0052] S104. The microcontroller outputs the virtual register configuration information to the external device based on the detection signal from the external device.
[0053] S105. The external device determines whether the enable signal contained in the enable signal information is valid.
[0054] Generally, to access a virtual register, the microcontroller enables the address space containing the virtual register's address. The enable signal is then valid; for example, a valid enable signal value can be 1. The enable signal can be stored directly in a register at the top level or transmitted via the bus. External devices can only access the corresponding virtual register when the enable signal is valid.
[0055] S106. When the enable signal is valid, the external device obtains the operation command corresponding to the access signal based on the address information.
[0056] S107. The external device executes the operation command.
[0057] It should be noted that the external devices (hereinafter referred to as peripherals) described in the first aspect of the embodiments refer to off-chip peripherals. Off-chip peripherals are functional modules or devices outside of a microcontroller (e.g., a single-chip microcontroller). These functional modules or devices can be selectively added outside the single-chip microcontroller or MCU according to the needs of those skilled in the art, which can bring additional functions or improve the performance of the single-chip microcontroller or MCU. In some embodiments, the external device may be an LCD, an A / D conversion chip, etc.
[0058] In the above embodiments, the microcontroller (MCU) generates register configuration information based on the access signal to the address space of the virtual register and sends it to the external device, enabling the external device to execute the operation command corresponding to the access signal, thereby achieving the purpose of controlling the external device. In other words, the microcontroller transmits the operation command information carried by the access signal to the external device through the virtual register, so that the microcontroller can still control the external device even in the absence of a peripheral control module.
[0059] Based on the above embodiments, this application proposes a method for mapping the internal address space of an MCU to an actual peripheral device. In this scheme, the use of virtual register space and the functionality of RTL design are not limited. It only requires simple detection of whether the MCU system has enabled the corresponding address space and outputs the corresponding address to map the corresponding address to the peripheral device, realizing the transfer of information between the MCU and the peripheral device and improving the flexibility of circuit simulation. In some embodiments, the address can be an address where the microcontroller accesses the external device, or an address of the external device mapped to a register on the microcontroller that is accessible to the microcontroller.
[0060] In some embodiments, such as Figure 2As shown, step S106, when the enable signal is valid, the external device obtains the operation instruction corresponding to the access signal according to the address information; including:
[0061] S201, the external device assigns a specified value to the physical register used to transmit command information according to the address information; the physical register is a register that has a mapping relationship with the virtual register.
[0062] S202, The external device obtains the operation command according to the specified value.
[0063] In some embodiments, when the physical register is assigned a first specified value, the operation command is to assign a value to a specific register in the external device.
[0064] In some embodiments, when the physical register is assigned a second specified value, the operation command is to reset the external device.
[0065] In some embodiments, such as Figure 3 As shown, MCU_Top is the MCU system, which is embedded in SoC_Top along with the ROM and peripheral modules. The C program (*.c) is compiled to generate a hexadecimal file (*ROM.txt), which is written to the ROM of the microcontroller MCU. The ROM reads the hexadecimal file (*ROM.txt) and sends it to the MCU. This is the process of running the C program in the simulation.
[0066] After the MCU obtains the access signal from the ROM input, it can execute the aforementioned steps S101-S107 and steps S201-S202.
[0067] exist Figure 3 In the illustrated implementation, besides mapping the virtual register R1, the C program also controls the peripherals. However, in the absence of a corresponding peripheral control module, the MCU primarily controls the peripherals by sending register configuration information. Specifically, accessing the virtual register R1 indicates that the user wants to perform a corresponding operation on the peripheral; this can be by passing a fixed value or a flag indicating an operation (such as resetting the peripheral). This solution is proposed for more flexible and efficient simulation.
[0068] The process for passing in a fixed value can be as follows: When the virtual register R1 is accessed by the first access signal, the physical register r1 in the peripheral is assigned the first value corresponding to the first access signal, and a specific register in the peripheral is assigned a value based on the first value.
[0069] The process for passing a flag for a certain operation (such as resetting a peripheral) can be as follows: When the virtual register R1 is accessed by the second access signal, the physical register r1 in the peripheral is assigned the second value corresponding to the second access signal, and the peripheral is reset according to the second value.
[0070] <Second aspect of this application>
[0071] A second aspect of this application provides a method for a microcontroller to communicate with an external device, including:
[0072] The microcontroller outputs virtual register configuration information to the external device based on the detection signal from the external device, so that the external device can execute operation commands;
[0073] The virtual register is defined within the address space of the microcontroller; the virtual register configuration information is generated by the microcontroller based on the access signal to its virtual register, and the virtual register configuration information includes address information and enable signal information for accessing the virtual register; the address information includes the address value of the access signal, and the operation command is the command corresponding to the access signal.
[0074] Furthermore, the enable signal information is used to enable the external device to obtain a valid enable signal, and when a valid enable signal is obtained, the operation command is obtained according to the address information.
[0075] In the above embodiments, the microcontroller (MCU) generates register configuration information based on the access signal to the virtual register and sends it to the external device, enabling the external device to execute the operation command corresponding to the access signal, thereby achieving the purpose of controlling the external device. In other words, the microcontroller transmits the operation command information carried by the access signal to the external device through the virtual register, so that the microcontroller can still control the external device even in the absence of a peripheral control module.
[0076] <Third aspect of this application>
[0077] A third aspect of this application provides a method for a microcontroller to communicate with its external devices, including:
[0078] The external device detects the microcontroller to obtain virtual register configuration information and executes operation commands based on the virtual register configuration information;
[0079] The virtual register is defined within the address space of the microcontroller; the virtual register configuration information is generated by the microcontroller based on the access signal to its virtual register, and the virtual register configuration information includes address information and enable signal information for accessing the virtual register; the address information includes the address value of the access signal, and the operation command is the command corresponding to the access signal.
[0080] In the above embodiments, the external device obtains and executes the corresponding operation commands by receiving the register configuration information output by the microcontroller (MCU). In this way, even in the absence of an external control module, the microcontroller can still control the external device.
[0081] In some implementations, such as Figure 4 As shown, the external device detects the virtual register configuration information acquired by the microcontroller and executes operation commands based on the virtual register configuration information, including:
[0082] S301. The external device detects whether the microcontroller generates the virtual register configuration information;
[0083] S302, The external device determines whether the enable signal contained in the enable signal information is valid;
[0084] S303. When the enable signal is valid, the external device obtains the operation command based on the address information;
[0085] S304. The external device executes the operation command.
[0086] In some implementations, such as Figure 5 As shown, in step S303, when the enable signal is valid, the external device obtains the operation command based on the address information; including:
[0087] S401, the external device assigns a specified value to the physical register used for transmitting command information according to the address information; the physical register is a register that has a mapping relationship with the virtual register;
[0088] S402, The external device obtains the operation command according to the specified value.
[0089] <Fourth aspect of this application>
[0090] A fourth aspect of this application provides a microcontroller, including:
[0091] A processor and a memory, wherein the memory stores a computer instruction program that can run on the processor, and the computer instruction program, when executed by the processor, implements the steps of the method for communicating between a microcontroller and an external device as described in the second aspect embodiment.
[0092] <Fifth aspect of this application>
[0093] A fifth aspect of this application provides an external device for a microcontroller, comprising:
[0094] A processor and a memory, wherein the memory stores a computer instruction program that can run on the processor, and the computer instruction program, when executed by the processor, implements the steps of the method for communicating between a microcontroller and an external device as described in the third aspect embodiment.
[0095] <Sixth aspect of this application>
[0096] A sixth aspect of this application provides a microcontroller system, including:
[0097] The microcontroller described in the fourth aspect; and
[0098] The external device described in the fifth aspect.
[0099] Although embodiments of the present invention have been disclosed above, they are not limited to the applications listed in the specification and embodiments. They can be applied to various fields suitable for the present invention. For those skilled in the art, other modifications can be easily made. Therefore, without departing from the general concept defined by the claims and their equivalents, the present invention is not limited to the specific details and illustrations shown and described herein.
Claims
1. A method of communication of a microcontroller with an external device, characterized in that, The method is applied to digital circuit design simulation, and comprises the steps of: The microcontroller receives an access signal for a virtual register thereof, wherein the virtual register is defined in an address space of the microcontroller; The microcontroller generates corresponding virtual register configuration information according to the access signal, wherein the virtual register configuration information comprises address information and enable signal information for accessing the virtual register, and the address information comprises a signal value of the access signal; The external device detects the microcontroller to obtain the virtual register configuration information; The microcontroller outputs the virtual register configuration information to the external device according to a detection signal of the external device; The external device judges whether the enable signal contained in the enable signal information is valid; When the enable signal is valid, the external device obtains an operation command corresponding to the access signal according to the address information; The external device executes the operation command; When the enable signal is valid, the external device obtains an operation command corresponding to the access signal according to the address information, comprising: The external device assigns a specified value to a physical register for transmitting command information according to the address information, wherein the physical register is a register having a mapping relationship with the virtual register; The external device obtains the operation command according to the specified value.
2. The method of claim 1, wherein, When the physical register is assigned a first specified value, the operation command is to assign a specific register in the external device, and when the physical register is assigned a second specified value, the operation command is to reset the external device.
3. A microcontrol system for implementing the method of any one of claims 1-2, comprising a microcontroller and an external device.
Citation Information
Patent Citations
Device controller and data processing apparatus
JP2008011273A