Contact card data transmission system and control method thereof

By using specific pin connections and control methods of a general-purpose MCU in the contact card communication system, the problem of high hardware cost was solved, the function of the ISO7816 interface was realized, and the versatility of the system was improved.

CN114565069BActive Publication Date: 2024-11-08GUOCHUANG INNOVATION CENTER OF MOBILE ENERGY (JIANGSU) CO.,LTD.
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210088053.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-25
Publication Date
2024-11-08
Estimated Expiration
2042-01-25

AI Technical Summary

Technical Problem

Existing contact card communication devices require dedicated MCUs, resulting in high hardware costs and difficulty in selecting MCUs.

Method used

The PWM output pin of the general-purpose MCU is connected to the clock input pin of the contact card, the GPIO pin is connected to the IO pin, the external clock input pin of the timer is connected to the PWM output pin, and the PWM frequency and duty cycle are set. The comparator mode and timer control interface are used for communication.

Benefits of technology

The ISO7816 interface function was implemented, which reduced hardware costs and improved the system's versatility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114565069B_ABST
    Figure CN114565069B_ABST
Patent Text Reader

Abstract

The present invention provides a data transmission system for a contact card and a control method thereof, wherein the data transmission system for the contact card comprises: a contact card and an MCU, wherein a PWM output pin of the MCU is connected to a clock input pin of the contact card, a GPIO pin of the MCU is connected to an IO pin of the contact card, and a timer external clock input pin of the MCU is connected to a PWM output pin of the MCU. According to the data transmission system for the contact card of the present invention, the function of the ISO7816 interface can be realized by using a universal MCU, which greatly reduces the hardware cost and improves the versatility of the system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data transmission, and in particular to a data transmission system of a contact card and a control method of a data reading system of a contact card. Background Art

[0002] With the widespread use of smart cards, the demand for card reader devices is also increasing. Card reader devices include contact and contactless types, among which contact card communication needs to comply with the ISO7816-3 standard card reading timing. Therefore, it is necessary to use an external expansion card reader chip or a dedicated MCU with an ISO7816 interface, which undoubtedly greatly increases the cost of the equipment and the difficulty of MCU selection. Summary of the invention

[0003] In order to solve the above technical problems, the present invention provides a data transmission system for contact cards, which can realize the functions of ISO7816 interface by using a universal MCU, greatly reducing the hardware cost and improving the versatility of the system.

[0004] The technical solution adopted by the present invention is as follows:

[0005] A data transmission system for a contact card comprises: the contact card and an MCU, wherein a PWM output pin of the MCU is connected to a clock input pin of the contact card, a GPIO pin of the MCU is connected to an IO pin of the contact card, and a timer external clock input pin of the MCU is connected to a PWM output pin of the MCU.

[0006] The PWM output frequency of the MCU is set to 1-5MHz, and the PWM duty cycle of the MCU is set to 33%-67%. The timer of the MCU uses an external clock source. The timer of the MCU adopts a comparator mode, wherein the comparator overflow automatic reload is set to 0, and the comparator threshold is set to 186.

[0007] A control method for a data reading system of a contact card comprises the following steps: when the MCU sends the first data to the contact card, judging whether a timer interrupt is triggered; if the timer interrupt is triggered, the interrupt counter is automatically incremented by 1; judging whether the interrupt counter is an odd number; if the interrupt counter is an odd number, judging whether the interrupt counter is 1; if the interrupt counter is 1, setting the IO pin of the contact card to a low level and sending a start bit; if the interrupt counter is not 1, judging whether the interrupt counter is K, wherein K is an odd number greater than 3; if the interrupt counter is K, setting the IO pin of the contact card and sending a parity bit; if the interrupt counter is not K, judging whether the interrupt counter is K+2; if the interrupt counter is not K+2, setting the IO pin of the contact card and sending the first data; if the interrupt counter is K+2, setting the IO pin of the contact card to a high level, ending the sending of the first data, and setting the interrupt counter to zero.

[0008] The control method of the data reading system of the contact card also includes the following steps: when the MCU reads the second data of the contact card, judging whether a timer interrupt is triggered; if the timer interrupt is triggered, the interrupt counter is automatically increased by 1; judging whether the interrupt counter is an even number; if the interrupt counter is an even number, judging whether the interrupt counter is 2; if the interrupt counter is 2, judging whether the IO pin of the contact card is at a low level, and when judging that the IO pin of the contact card is at a low level, setting the interrupt counter to zero; if the interrupt counter is not 2, judging whether the interrupt counter is K+1; if the interrupt counter is not K+1, reading the saved bit data of the IO pin of the contact card; if the interrupt counter is K+1, reading the parity bit of the IO pin of the contact card; judging whether the read second data is normal according to the parity bit; if normal, saving the second data and setting the interrupt counter to zero; if abnormal, giving an abnormal alarm and setting the interrupt counter to zero.

[0009] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the control method of the contact card data reading system is implemented.

[0010] A non-temporary computer-readable storage medium stores a computer program, which implements the control method of the contact card data reading system when executed by a processor.

[0011] Beneficial effects of the present invention:

[0012] The present invention can realize the function of ISO7816 interface by using a universal MCU, which greatly reduces the hardware cost and improves the versatility of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 A block diagram of a data transmission system for a contact card according to an embodiment of the present invention;

[0014] Figure 2 It is a flow chart of a control method of a data transmission system of a contact card according to an embodiment of the present invention;

[0015] Figure 3 The present invention is a flowchart of a control method of a data transmission system of a contact card according to an embodiment of the present invention. DETAILED DESCRIPTION

[0016] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0017] Figure 1 4 is a block diagram of a data transmission system for a contact card according to an embodiment of the present invention.

[0018] like Figure 1 As shown, the data transmission system of the contact card of the embodiment of the present invention may include: a contact card 100 and an MCU (Micro Control Unit) 100. Among them, the PWM output pin of the MCU 200 is connected to the clock input pin (CLK pin) of the contact card 100, the GPIO pin of the MCU 200 is connected to the IO pin of the contact card 100, and the timer external clock input pin (TIMER CLK pin) of the MCU 200 is connected to the PWM output pin of the MCU 200.

[0019] Specifically, the ISO7816 interface needs to introduce etu as the basic time unit, where 1etu=372 / f, and f is the clock frequency. Therefore, after using the PWM output of MCU200 as the clock input of the contact card, and connecting the GPIO pin of MCU200 to the IO port of the contact card 100, and connecting the PWM pin of MCU200 and the external clock input pin of the timer of MCU200, the PWM output frequency of MCU200 can be set to 1-5MHz, and the duty cycle of MCU200 can be set to 33% to 67% (for example, it can be 50%) to simulate the clock that conforms to the ISO7816 interface, and the timer of MCU200 is set to select the external clock source, and the timer of MCU200 adopts the comparator mode, and the comparator overflow automatic reload is set to 0, and the comparator threshold is set to 186. At this time, the timer interrupt interval meets the 0.5etu time of the ISO7816 interface. On this basis, the communication function of the contact card 100 can be accurately completed.

[0020] The data transmission system of the contact card according to the embodiment of the present invention comprises: a contact card and an MCU, wherein the PWM output pin of the MCU is connected to the clock input pin of the contact card, the GPIO pin of the MCU is connected to the IO pin of the contact card, and the timer external clock input pin of the MCU is connected to the PWM output pin of the MCU. Thus, the function of the ISO7816 interface can be realized by using a universal MCU, which greatly reduces the hardware cost and improves the versatility of the system.

[0021] The following describes in detail how the data reading system based on the contact card realizes the communication function of the contact card 100 in conjunction with specific embodiments.

[0022] Specifically, before the MCU transmits data with the contact card, the PWM output pin of the MCU can be initialized first, and the MCU timer can be initialized, the capture mode can be set and the external clock can be used, and the timer interrupt counter can be cleared, the timer interrupt can be enabled, and the PWM output pin of the MCU can be turned on.

[0023] Furthermore, if Figure 2 As shown, when sending data to a contact card through an MCU, a control method of a data reading system of a contact card may include the following steps:

[0024] S201, when the MCU sends first data to the contact card, it is determined whether a timer interrupt is triggered.

[0025] S202: If the timer interrupt is triggered, the interrupt counter is automatically incremented by 1.

[0026] S203, determining whether the interrupt counter is an odd number.

[0027] S204: If the interrupt counter is an odd number, determine whether the interrupt counter is 1.

[0028] S205, if the interrupt counter is 1, the IO pin of the contact card is set to a low level and a start bit is sent.

[0029] S206: If the interrupt counter is not 1, determine whether the interrupt counter is K, where K is an odd number greater than 3. For example, K may be 19.

[0030] S207, if the interrupt counter is K, set the IO pin of the contact card and send the parity bit;

[0031] S208, if the interrupt counter is not K, determine whether the interrupt counter is K+2;

[0032] S209, if the interrupt counter is not K+2, setting the IO pin of the contact card and sending the first data;

[0033] S210, if the interrupt counter is K+2, the IO pin of the contact card is set to a high level, the sending of the first data is terminated, and the interrupt counter is set to zero.

[0034] Furthermore, if Figure 3 As shown, when sending data to the contact card through the MCU, the control method of the contact card data reading system may further include the following steps:

[0035] S301, when the MCU reads the second data of the contact card, it is determined whether a timer interrupt is triggered.

[0036] S302: If the timer interrupt is triggered, the interrupt counter is automatically incremented by 1.

[0037] S303, determining whether the interrupt counter is an even number.

[0038] S304: If the interrupt counter is an even number, determine whether the interrupt counter is 2.

[0039] S305, if the interrupt counter is 2, determine whether the IO pin of the contact card is at a low level, and when it is determined that the IO pin of the contact card is at a low level, reset the interrupt counter to zero.

[0040] S306: If the interrupt counter is not 2, determine whether the interrupt counter is K+1.

[0041] S307, if the interrupt counter is not K+1, read the IO pin of the contact card to save the bit data.

[0042] S308, if the interrupt counter is K+1, read the parity bit of the IO pin of the contact card.

[0043] S309, judging whether the read second data is normal according to the parity bit.

[0044] S310: If normal, save the second data and set the interrupt counter to zero.

[0045] S311, if abnormal, an abnormal alarm is issued and the interrupt counter is reset to zero.

[0046] According to the control method of the data reading system of the contact card of the embodiment of the present invention, the method comprises the following steps: when the MCU sends the first data to the contact card, it is judged whether the timer interrupt is triggered; if the timer interrupt is triggered, the interrupt counter is automatically increased by 1; it is judged whether the interrupt counter is an odd number; if the interrupt counter is an odd number, it is judged whether the interrupt counter is 1; if the interrupt counter is 1, the IO pin of the contact card is set to a low level and a start bit is sent; if the interrupt counter is not 1, it is judged whether the interrupt counter is K, wherein K is an odd number greater than 3; if the interrupt counter is K, the IO pin of the contact card is set and a parity check bit is sent; if the interrupt counter is not K, it is judged whether the interrupt counter is K+2; if the interrupt counter is not K+2, the IO pin of the contact card is set and the first data is sent; if the interrupt counter is K+2, the IO pin of the contact card is set to a high level, the sending of the first data is terminated, and the interrupt counter is set to zero. Thus, the function of the ISO7816 interface can be realized by using a universal MCU, which greatly reduces the hardware cost and improves the versatility of the system.

[0047] Corresponding to the above embodiment, the present invention also provides a computer device.

[0048] The computer device of the embodiment of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the control method of the contact card data reading system of the above embodiment is implemented.

[0049] According to the computer device of the embodiment of the present invention, the function of the ISO7816 interface can be realized by using a general MCU, which greatly reduces the hardware cost and improves the versatility of the system.

[0050] Corresponding to the above embodiment, the present invention also proposes a non-transitory computer-readable storage medium.

[0051] A non-transitory computer-readable storage medium in an embodiment of the present invention stores a computer program, and when the program is executed by a processor, the control method of the contact card data reading system is implemented.

[0052] According to the non-transitory computer-readable storage medium of the embodiment of the present invention, the function of the ISO7816 interface can be implemented by using a general MCU, which greatly reduces the hardware cost and improves the versatility of the system.

[0053] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. "Multiple" means two or more, unless otherwise clearly and specifically defined.

[0054] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0055] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.

[0056] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.

[0057] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.

[0058] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or otherwise processing in a suitable manner if necessary, and then stored in a computer memory.

[0059] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0060] A person skilled in the art may understand that all or part of the steps in the above-mentioned embodiment method may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0061] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0062] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.

Claims

1. A data transmission system for a contact card, characterized in that: include: The contact card and MCU, wherein the PWM output pin of the MCU is connected to the clock input pin of the contact card, the GPIO pin of the MCU is connected to the IO pin of the contact card, and the external clock input pin of the timer of the MCU is connected to the PWM output pin of the MCU; wherein the PWM output frequency of the MCU is set to 1-5MHz, and the PWM duty cycle of the MCU is set to 33%-67%, the timer of the MCU selects an external clock source, and the timer of the MCU adopts a comparator mode, wherein the comparator overflow automatic reload is set to 0, and the comparator threshold is set to 186.

2. A control method for a data transmission system based on a contact card according to claim 1, characterized in that: The following steps are involved: When the MCU sends the first data to the contact card, determining whether a timer interrupt is triggered; If the timer interrupt is triggered, the interrupt counter automatically increases by 1; Determining whether the interrupt counter is an odd number; If the interrupt counter is an odd number, determining whether the interrupt counter is 1; If the interrupt counter is 1, the IO pin of the contact card is set to a low level and a start bit is sent; If the interrupt counter is not 1, determining whether the interrupt counter is K, where K is an odd number greater than 3; If the interrupt counter is K, the IO pin of the contact card is set and a parity bit is sent; If the interrupt counter is not K, determining whether the interrupt counter is K+2; If the interrupt counter is not K+2, setting the IO pin of the contact card and sending the first data; If the interrupt counter is K+2, the IO pin of the contact card is set to a high level, the sending of the first data is terminated, and the interrupt counter is reset to zero.

3. The control method of the data transmission system of the contact card according to claim 2, characterized in that: The following steps are also included: When the MCU reads the second data of the contact card, determining whether to trigger a timer interrupt; If the timer interrupt is triggered, the interrupt counter automatically increases by 1; Determining whether the interrupt counter is an even number; If the interrupt counter is an even number, determining whether the interrupt counter is 2; If the interrupt counter is 2, determine whether the IO pin of the contact card is at a low level, and when it is determined that the IO pin of the contact card is at a low level, reset the interrupt counter to zero; If the interrupt counter is not 2, determining whether the interrupt counter is K+1; If the interrupt counter is not K+1, reading the saved bit data of the IO pin of the contact card; If the interrupt counter is K+1, reading the parity bit of the IO pin of the contact card; Determining whether the second data read is normal according to the parity bit; If normal, saving the second data and setting the interrupt counter to zero; If it is abnormal, an abnormal alarm is issued and the interrupt counter is reset to zero.

4. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the control method of the data transmission system of the contact card according to any one of claims 2 and 3 is implemented.

5. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the control method of the data transmission system of the contact card according to any one of claims 2 and 3 is implemented.