|
Author Email: zhaoyn2001@163.net Abstract: Developed based on the Windows2000 environment 1394 master control machine between has carried on the serial main line correspondence with 1394 equipment machine the software and hardware system, has used the multi-thread technology, and realized the thread using the critical zone the shared resource synchronization, thus has solved in the serial communication real-time response problem effectively, reduced the data loss rate, enhanced system’s reliability. Key word: Multithreading; 1394 main lines; Thread synchronization 1 introduction For ease of the LS-1394 physics level, the link level chip design topic’s research, we used FPGA and the ISA main line have developed based on TI Corporation’s TSB41AB3 and the TSB12LV01 ISA-1394 1394 bus interface card, and developed a set under the Windows2000 environment to realize using the multi-thread technology 1394 master control machine between carries on the serial communication with 1394 equipment machine the software system. 2 hardware parts The hardware part mainly includes: 1394 master control machine, 1394 equipment machine, PCI-1394 card, ISA-1394 card. And, the PCI-1394 card is the TI Corporation’s 1394 bus interface chip control card, this card inserts in 1394 master control machine PCI slots; The ISA-1394 card is the use model is 1394 bus interface chip control card which together EPM7256AETC144-5 FPGA, together TI Corporation’s TSB12LV01 link level chip and the TSB41AB3 physics level chip independently designs together, this card inserts in 1394 equipment’s machine ISA slots. 1394 master control machine and between 1394 equipment machine carry on the serial communication through 1394 connections, the transmission medium are 1394 cables. Hardware structure drawing as shown in Figure 1.
3 software parts The software design mainly includes 1394 master control machine ends and 1394 equipment machine end two major parts, because 1394 master control machine ends have the ready-made demo application procedure, therefore the software design mainly aims at 1394 equipment machine ends. 1394 equipment machine end’s programming environment is WinDriver 5.0 and VC 6.0. 3.1 software design thought 1394 serial main lines have two mailing addresss: Isochronal correspondence and asynchronous communication. What the asynchronous communication uses is the request/reply pattern, the data transmission reliability is high, therefore here mainly discusses the asynchronous communication. 1394 serial main line asynchronous communication’s principle is: When transmission data packet, waits for the transmitter to be idle, writes about 1394 link level chip the data packet in transmission FIFO to transmit; When receive data packet, once has the data packet to arrive, the receiver will put the data packet to 1394 link level chip receive FIFO, after receiving the data packet, must transmit a reply package immediately, otherwise, opposite party will reissue this data packet, until reproduction number of times. What must pay attention, the user must visit voluntarily receives FIFO to examine whether to have the data packet and take out the data packet promptly, will otherwise cause to receive the FIFO overflow, the obliterated data, will cause the correspondence to make a mistake. In the serial communication programming, usually uses fixed time inquires or the interrupt solves the above problem, uses the interrupt the method compared to fixed time to inquire the law to have the higher working efficiency and the reliability, therefore this system uses the interrupt law to complete 1394 serial main line’s data communications. In order to realize the data processing and the data receive and the transmission separation, this system has introduced the multi-thread technology. Founds a user thread again in outside the application procedure’s main thread, namely the interrupt processing thread, realizes the data packet receive and the transmission in the interrupt processing thread. If the receive interrupt arrival, the interrupt processing thread responsibly takes out receives in FIFO the data, puts to user definition receive buffer rBuf; If the transmission interrupt arrival, the interrupt processing thread is responsible from user definition transmission buffer sBuf to take out the data to put to transmits in FIFO to transmit. The main thread is responsible to transfer the explanation disposal procedure to carry on explanation processing to the rBuf data packet, or transfers other procedures to write the request data packet for sBuf. Because many threads may visit in the identical advancement the public data, therefore in the use multithreading’s process needs to pay attention how does the question is prevent two or two above threads simultaneously visits the identical data, in order to avoid destruction data integrity. In this system, when the interrupt processing thread takes the data packet from transmission buffer sBuf, if this time has a thread to write the data packet for transmission buffer sBuf, like this existence visit transmission buffer sBuf resources conflict, namely so-called thread not synchronization question. In view of this question, in the system uses the critical zone to come to solve. It may guarantee in some time only then a thread may visit sBuf, through establishes a sharing in the different thread the critical zone object, regardless of which thread holds the critical zone object, may visit sBuf which protects, at this time other threads need to wait for, until this thread release critical zone object. After the critical zone releases, other thread may usurp this critical zone, with the aim of visiting sBuf. 3.2 software architectures Based on multi-thread technology’s 1394 serial main line communications system software architecture as shown in Figure 2. Various modules’ function is as follows: 1) main thread: Front end the response user’s input, provides the man-machine interaction contact surface; Completes the thread the foundation, the termination and the thread synchronization; The receive thread sends in the news, and transfers the corresponding thread disposal procedure; 2) interrupt processing thread: When receive interrupt arrival, receives in GRF the data packet to put to receive buffer rBuf, and receives the data packet to the main thread transmission the news, when transmission interrupt arrival, takes out the data packet from transmission buffer sBuf to write about in ATF; 3) explains the disposal procedure: Takes out after receive buffer rBuf the data packet carries on explanation processing puts dataBuf, and constructs responds Bao Fangdao to transmit in buffer sBuf; 4) initialization routine: Initialization serial port resources and procedure establishment; 5) other procedures: Takes the data from data buffer dataBuf to carry on further processes, or writes the request data packet for transmission buffer sBuf. This software uses the multi-thread technology, front end causes the man-machine interaction part, the middle processing part and the backstage serial port correspondence part parallel processing, lets the time-consuming I/O correspondence in the backstage movement, to improves the procedure in the great data quantity correspondence’s situation the speed of response is quite effective. 3.3 procedure contents 1394 equipment machine end’s procedure mainly by the ISA connection card’s driver, the initialization routine, the interrupt handling routine and the explanation disposal procedure four major main parts is composed. 3.3.1 drivers Because WinDriver has the formidable equipment to actuate the development ability, supports under the user pattern to carry on directly visit to the hardware, and WinDriver provides the driver develops guide DriverWizard to be possible to produce the driver frame automatically, reduced the device driver development difficulty greatly, reduced the development time, therefore the ISA connection card’s driver develops under WinDriver. The driver mainly completes to ISA the connection card I/O address read-write and to hardware interrupt processing. This ISA the card I/O port address is: 0×300~0×510; The interrupt number is 9. 3.3.2 initialization routines Before starting the correspondence, must first to the serial port resources, the link level register and the procedure establishment carries on the initialization, including the link level register initialization, to open actuates the equipment, to open work and so on hardware interrupt, definition critical zone object and receiving and dispatching buffer. CCriticalSection m_cs; file:// definition critical zone object The link level register initialization is 1394 serial main lines can the normal work foundation, gets down the chart is the link level register initialization flow graph. Replacement interrupt register IntFlagReg, causes it is zero; Writes interrupt mask register IntMaskReg, opens the interrupt permission to enable the position, the transmission interrupt position and the receive interrupt position; Writes FIFO control register FifoCtrlReg, eliminates receives and transmits FIFO, and establishes receives and transmits FIFO the size; Writes physical level chip visit register PhyAccessReg, the initialization main line repositions; Writes control register ControlReg, opens the transmission, the receive enables the position and so on.
3.3.3 interrupt handling routine InterruptHandle() is an overall situation interrupt processing function, it has been waiting for the hardware interrupt, once has the interrupt arrival immediately to respond. The concrete form is as follows: UINT InterruptHandle (LPVOID wParam) 3.3.4 explanation disposal procedure The explanation disposal procedure in fact is the user from a definition message handling function, it has been waiting for the interrupt handling routine sends in receive data packet news. If has the news to arrive, takes out the data packet from rBuf to carry on the explanation. If from marks the package, will receive the data puts to from marking buffer SelfIDbuf in; If is reads requests the package, takes out the data from dataBuf, and according to reads the request data packet Baotou to construct correspondingly reads responds in Bao Fangdao sBuf; If is writes requests the package, takes out the data part from rBuf to put to data buffer dataBuf in waited for that makes further processing, and according to writes the request data packet Baotou to construct correspondingly writes responds in Bao Fangdao sBuf. 4 concluding remark This article in view of the practical application to 1394 serial main line correspondence timeliness and the reliable request, uses the interrupt the method to receive and the transmission data, and proposed realizes 1394 serial main line asynchronous communication method under Windows2000 using the multi-thread technology, the effective solution the data missing which appeared in the serial port correspondence and the unstable question, enhanced the system to carry out the efficiency and the resources use factor, the practice proved that this was one effective way. |
51 Research and Design, Electronic Engineers website - Embedded Systems, MCU, DSP, EDA, Test and Measurement, Components, Communications, Power, Microelectronics, Semiconductors
Electronic Design and Research - Electronic Engineers website


