Design of Tax Controller Application Scheme Based on μPSD32XX Single-chip Microcomputer

According to the modularization concept, the hardware adopts a module + backplane architecture, the main processing and core hardware are concentrated ON the module, and the power supply and connectors are placed on the backplane. The bottom layer of the software adopts the form of API function to the upper layer. Through products and services in the form of devices, software and hardware development platforms, solutions, and full-featured modules, a variety of development and cooperation models can be constructed, which will help promote the mass production of complete machine manufacturers, reduce costs and save time .

Author: You Long

introduction

Tax control equipment is one of the inevitable means for the national taxation department to implement tax management information. As one of the tax control equipment, the tax control device is an Electronic device that realizes the tax control function with the cooperation of computers and other electronic equipment to ensure the operation data. Correct generation, reliable storage and secure transmission can meet the management and data verification requirements of tax authorities. The tax controller is an embedded system that integrates software and hardware. In order to improve development efficiency and versatility, it adopts a modular design and a hierarchical structure to achieve as much as possible the flexibility of hardware and the portability of software.

Features of μPSD32XX MCU

The software can be designed, compiled and simulated in KEIL’s KEIL 51 integrated development environment μVision2, and ST’s PSDsoft Express software can be used for programming download and internal configuration. The software can configure the on-chip FLASH, SRAM and PLD of μPSD32XX series single-chip microcomputers, merge the compiled program code files (.HEX) and configuration files to generate .OBJ files, and download them to the single-chip microcomputer. When downloading, you need to use the FlashLINK programming cable to connect the standard parallel port of the PC and the JTAG port of the microcontroller.

Tax controller application scheme design

The tax control platform should have some basic functions: a real-time clock and a large-capacity memory for recording tax control data, an IC card reader that complies with the ISO 7816 standard, supports tax control cards, user cards and tax management cards, via USB or serial ports It communicates with the host and has a backup battery that can save memory data and clock operation after power failure. As an external device, the tax controller is connected as shown in Figure 1, and the internal hardware system structure is shown in Figure 2.

Design of Tax Controller Application Scheme Based on μPSD32XX Single-chip Microcomputer

Design of Tax Controller Application Scheme Based on μPSD32XX Single-chip Microcomputer

The main control module MCU adopts the μPSD3234A single-chip microcomputer of ST Company, which has 256KB of main FLASH, 32KB of secondary FLASH and 32KB SRAM inside, the working voltage is 5V, and the crystal oscillator is 24MHz. Among them, the SRAM is protected by an off-chip backup battery, which can store some long-term stored data and maintain a current of 1μA. It is connected to the host through USB or UART, connected to RTC through I2C, and connected to ICC and MEM through general I/O.

The clock module RTC adopts ST’s M41T0M6, provides real-time clock/calendar function, and is powered by an off-chip backup battery after the system is powered off.

The memory uses ST’s serial FLASH M25P16 with a capacity of 2MB, which is mainly used to store invoice data and tax control data. The maximum transmission rate of the SPI bus interface is 50MHz, and the operating Voltage is 3.3V.

The IC card module ICC uses ON semiconductor’s NCN6004A, dual card interface, conforms to ISO 7816-3 and EMV standards, and the MCU communicates with it through the I/O line. In order to save I/O resources, a multiplex connection method can be selected. The two cards share one channel and are distinguished by the card selection signal to realize the access function of the tax control card and the user card respectively.

USB communication adopts STF202 of ON Semiconductor as terminal matching, filtering and ESD protection, and the communication rate is 1.5Mbps. Because MCU has SIE, FIFO and transceiver inside, SIE can turn the transmission signal into bytes and store it in the register, so by configuring the SIE in advance, and then accessing the defined address and port, communication control, interruption, and sending and receiving are realized. And so on.

The level conversion chip of UART adopts HIN202 of Intersil Company. There are 2 UARTs inside the MCU, all of which can be selected as RS232 communication.

In order to achieve electrical protection, ON Semiconductor’s boost chip NCP1402SN50T1 is used. When it is working normally, the large Capacitor is charged. Once the power is off, the large capacitor can still maintain the chip for a period of time. At this time, some important tasks can be completed to avoid An unexpected power failure generated an error. The large capacitor uses two winding-type Capacitors of 3.3F/2.5V in series, which can maintain power supply for more than 30s when fully charged.

Use ON Semiconductor’s NCP500SN33T1 as a 5V to 3.3V voltage converter with an output current of 150mA, which can be used for 3.3V devices to work. The backup battery uses two 3V/210mAh lithium batteries, which can be used for at least 10 years.

The monitoring module adopts MAX708 of ON Semiconductor to realize the functions of power-on reset and manual reset. MAX708 also has a voltage monitoring function, select an appropriate voltage divider Resistor at the PFI end, when the main power supply is powered off, it can generate a power failure interrupt signal.

The status indication adopts light-emitting diodes, which are respectively used to indicate the power-on, card insertion indication, and JATG program downloading status. Custom status indications can be connected to the I/O of the MCU, such as errors, running, self-testing and other statuses.

Software design plan

Design of Tax Controller Application Scheme Based on μPSD32XX Single-chip Microcomputer

The tax controller software should contain two parts as a whole: host-side software and device-side software. The data communication between the host and the device adopts the “command-response” mode. The host sends a command and the device responds.

The host-side software can be divided into four layers: application layer, tax control function layer, communication management layer, and device driver layer; device-side software can also be divided into four layers: main control layer, tax control function layer, device management layer, and hardware driver Floor. Here we mainly introduce the equipment-side software.

The main control function is responsible for the initialization of the system and equipment, communication monitoring with the host, protocol management, tax control command package interpretation and task scheduling.

The tax control function is designed in accordance with the requirements of the national standard for tax controllers. It is responsible for machine initialization and registration, invoice distribution, invoicing, refund, invalidation, upload of invoices, daily transaction and volume summary data, declaration, verification and other tax control applications.

The device management layer is a management program designed for complex devices, including IC card management, memory management, and USB communication management.

The IC card management program is to design the operation command program for the card in accordance with the requirements of the[GB 18240.2-2003]tax control IC card specification. The commands are divided into basic commands and extended commands. Basic commands include file operation, read and write records, random number generation, internal and external authentication, response fetching, application lock, etc.; tax control card special commands have card registration, invoicing, daily transaction signatures, etc.; user card special commands have registered signatures , Distribute invoices, summarize tax declaration data and other functions.

The memory management program is to perform address allocation management on the Flash storage space, and is designed according to the way of circular recording, completes the formatting, reading and writing, and searching of invoice details, daily transactions and volume summary records, and also manages the storage in SRAM Address allocation table, record pointer and other data.

The USB communication management program is designed in accordance with the specification of low-speed USB1.1 and the requirements of the human-machine interface device (HID) category to complete the bus enumeration and data communication transactions. It mainly uses Endpoint 0 (IN/OUT) to control the transmission mode, and uses the input and output report format to exchange data with the host.

The hardware driver layer is mainly the driver program that realizes the bottom operation of each hardware device, including API library functions such as clock, IC card, FLASH, UART and USB. The clock function realizes functions such as setting, reading and writing clock and calendar; the IC card function realizes the functions of IC card insertion detection, card power-on and power-off, card reset and card command; FLASH function realizes the erasing, reading and writing of external FLASH memory Data and other functions; UART and USB functions implement functions such as setting, receiving and sending data.

Summarize

According to the modularization concept, the hardware adopts a module + backplane architecture, the main processing and core hardware are concentrated on the module, and the power supply and connectors are placed on the backplane. The bottom layer of the software adopts the form of API function to the upper layer. Through products and services in the form of devices, software and hardware development platforms, solutions, and full-featured modules, a variety of development and cooperation models can be constructed, which will help promote the mass production of complete machine manufacturers, reduce costs and save time .

Author: You Long

introduction

Tax control equipment is one of the inevitable means for the national taxation department to implement tax management information. As one of the tax control equipment, the tax control device is an electronic device that realizes the tax control function with the cooperation of computers and other electronic equipment to ensure the operation data. Correct generation, reliable storage and secure transmission can meet the management and data verification requirements of tax authorities. The tax controller is an embedded system that integrates software and hardware. In order to improve development efficiency and versatility, it adopts a modular design and a hierarchical structure to achieve as much as possible the flexibility of hardware and the portability of software.

Features of μPSD32XX MCU

The software can be designed, compiled and simulated in KEIL’s KEIL 51 integrated development environment μVision2, and ST’s PSDsoft Express software can be used for programming download and internal configuration. The software can configure the on-chip FLASH, SRAM and PLD of μPSD32XX series single-chip microcomputers, merge the compiled program code files (.HEX) and configuration files to generate .OBJ files, and download them to the single-chip microcomputer. When downloading, you need to use the FlashLINK programming cable to connect the standard parallel port of the PC and the JTAG port of the microcontroller.

Tax controller application scheme design

The tax control platform should have some basic functions: a real-time clock and a large-capacity memory for recording tax control data, an IC card reader that complies with the ISO 7816 standard, supports tax control cards, user cards and tax management cards, via USB or serial ports It communicates with the host and has a backup battery that can save memory data and clock operation after power failure. As an external device, the tax controller is connected as shown in Figure 1, and the internal hardware system structure is shown in Figure 2.

Design of Tax Controller Application Scheme Based on μPSD32XX Single-chip Microcomputer

Design of Tax Controller Application Scheme Based on μPSD32XX Single-chip Microcomputer

The main control module MCU adopts the μPSD3234A single-chip microcomputer of ST Company, which has 256KB of main FLASH, 32KB of secondary FLASH and 32KB SRAM inside, the working voltage is 5V, and the crystal oscillator is 24MHz. Among them, the SRAM is protected by an off-chip backup battery, which can store some long-term stored data and maintain a current of 1μA. It is connected to the host through USB or UART, connected to RTC through I2C, and connected to ICC and MEM through general I/O.

The clock module RTC adopts ST’s M41T0M6, provides real-time clock/calendar function, and is powered by an off-chip backup battery after the system is powered off.

The memory uses ST’s serial FLASH M25P16 with a capacity of 2MB, which is mainly used to store invoice data and tax control data. The maximum transmission rate of the SPI bus interface is 50MHz, and the operating voltage is 3.3V.

The IC card module ICC uses ON Semiconductor’s NCN6004A, dual card interface, conforms to ISO 7816-3 and EMV standards, and the MCU communicates with it through the I/O line. In order to save I/O resources, a multiplex connection method can be selected. The two cards share one channel and are distinguished by the card selection signal to realize the access function of the tax control card and the user card respectively.

USB communication adopts STF202 of ON Semiconductor as terminal matching, filtering and ESD protection, and the communication rate is 1.5Mbps. Because MCU has SIE, FIFO and transceiver inside, SIE can turn the transmission signal into bytes and store it in the register, so by configuring the SIE in advance, and then accessing the defined address and port, communication control, interruption, and sending and receiving are realized. And so on.

The level conversion chip of UART adopts HIN202 of Intersil Company. There are 2 UARTs inside the MCU, all of which can be selected as RS232 communication.

In order to achieve electrical protection, ON Semiconductor’s boost chip NCP1402SN50T1 is used. When it is working normally, the large capacitor is charged. Once the power is off, the large capacitor can still maintain the chip for a period of time. At this time, some important tasks can be completed to avoid An unexpected power failure generated an error. The large capacitor uses two winding-type capacitors of 3.3F/2.5V in series, which can maintain power supply for more than 30s when fully charged.

Use ON Semiconductor’s NCP500SN33T1 as a 5V to 3.3V voltage converter with an output current of 150mA, which can be used for 3.3V devices to work. The backup battery uses two 3V/210mAh lithium batteries, which can be used for at least 10 years.

The monitoring module adopts MAX708 of ON Semiconductor to realize the functions of power-on reset and manual reset. MAX708 also has a voltage monitoring function, select an appropriate voltage divider Resistor at the PFI end, when the main power supply is powered off, it can generate a power failure interrupt signal.

The status indication adopts light-emitting diodes, which are respectively used to indicate the power-on, card insertion indication, and JATG program downloading status. Custom status indications can be connected to the I/O of the MCU, such as errors, running, self-testing and other statuses.

Software design plan

Design of Tax Controller Application Scheme Based on μPSD32XX Single-chip Microcomputer

The tax controller software should contain two parts as a whole: host-side software and device-side software. The data communication between the host and the device adopts the “command-response” mode. The host sends a command and the device responds.

The host-side software can be divided into four layers: application layer, tax control function layer, communication management layer, and device driver layer; device-side software can also be divided into four layers: main control layer, tax control function layer, device management layer, and hardware driver Floor. Here we mainly introduce the equipment-side software.

The main control function is responsible for the initialization of the system and equipment, communication monitoring with the host, protocol management, tax control command package interpretation and task scheduling.

The tax control function is designed in accordance with the requirements of the national standard for tax controllers. It is responsible for machine initialization and registration, invoice distribution, invoicing, refund, invalidation, upload of invoices, daily transaction and volume summary data, declaration, verification and other tax control applications.

The device management layer is a management program designed for complex devices, including IC card management, memory management, and USB communication management.

The IC card management program is to design the operation command program for the card in accordance with the requirements of the[GB 18240.2-2003]tax control IC card specification. The commands are divided into basic commands and extended commands. Basic commands include file operation, read and write records, random number generation, internal and external authentication, response fetching, application lock, etc.; tax control card special commands have card registration, invoicing, daily transaction signatures, etc.; user card special commands have registered signatures , Distribute invoices, summarize tax declaration data and other functions.

The memory management program is to perform address allocation management on the Flash storage space, and is designed according to the way of circular recording, completes the formatting, reading and writing, and searching of invoice details, daily transactions and volume summary records, and also manages the storage in SRAM Address allocation table, record pointer and other data.

The USB communication management program is designed in accordance with the specification of low-speed USB1.1 and the requirements of the human-machine interface device (HID) category to complete the bus enumeration and data communication transactions. It mainly uses Endpoint 0 (IN/OUT) to control the transmission mode, and uses the input and output report format to exchange data with the host.

The hardware driver layer is mainly the driver program that realizes the bottom operation of each hardware device, including API library functions such as clock, IC card, FLASH, UART and USB. The clock function realizes functions such as setting, reading and writing clock and calendar; the IC card function realizes the functions of IC card insertion detection, card power-on and power-off, card reset and card command; FLASH function realizes the erasing, reading and writing of external FLASH memory Data and other functions; UART and USB functions implement functions such as setting, receiving and sending data.

Summarize

According to the modularization concept, the hardware adopts a module + backplane architecture, the main processing and core hardware are concentrated on the module, and the power supply and connectors are placed on the backplane. The bottom layer of the software adopts the form of API function to the upper layer. Through products and services in the form of devices, software and hardware development platforms, solutions, and full-featured modules, a variety of development and cooperation models can be constructed, which will help promote the mass production of complete machine manufacturers, reduce costs and save time .

The Links:   CM200TU-12F RM100HA-20F