嵌入式操作系統 /
service /
1544
編輯
刪除
SCM also be known as micro-controller (Microcontroler), SCM only by the CPU chip, developed from a dedicated processor. The first design concept is by and large number of peripheral devices integrated in a CPU chip, the computer system is smaller, more easily integrated.
Early SCM are eight or the four. One of the most successful is the 8031 INTEL, because simple and reliable and good performance was praised. Since then in 8031 on the development of a series MCS51 SCM system. Based on this system until now the SCM system is still widely used. As the field of industrial control requirements of the increase, began to appear in 16-bit microcontrollers. As the 1990s after the big consumer electronics product development, SCM technology got a huge raise. With the emergence of INTEL i960 series, especially the later ARM wide range of applications, 32-bit microcontroller quickly replaced by 16 high-end MCU status and enter the mainstream market. And the traditional 8-bit microcontrollers performance has been improving rapidly, the capacity increase compared with the 1980s a few hundred times. At present, high-speed 32-bit microcontroller has exceeded 300 MHz, catching up performance of the mid-1990s, dedicated processors.
Contemporary SCM system is no longer only barebone environment in the development and use of a large number of dedicated embedded operating system is widely used in the SCM. As handheld computers and mobile phones with high-end microcontroller core can even direct the use of a dedicated Windows and Linux operating systems. SCM processor for more than suitable for embedded systems. In fact SCM is the world's largest number of computers. Modern human life used in almost every electronic and machinery products will integrate a microcontroller. Cell phone, telephone, calculator, household appliances, electronic toys, handheld computers and computer accessories such as a mouse with a 1-2 in both the Department of SCM. And personal computers will also have a large number of SCM at work. General vehicle equipped with more than 40 of the microcontroller, complex industrial control systems may have even hundreds of SCM at the same time work! SCM is not only far exceeded the number of PC and other integrated computing, or even than the number of human beings more. In SCM applications, the MCU anti-jamming system software debugging and MCU programming has been troubled for beginners. This article brief introduction of these two issues.
SCM system software interference methods
In improving the ability of anti-jamming system hardware, software interference with its flexible design, save hardware resources, more and more attention to reliability. Below the MCS-51 SCM system as an example, the computer system software interference methods for research.
In engineering practice, anti-jamming software on the content of the main ones being: 1, analog input signal to eliminate the noise (such as digital filter technology); two, is running the program when the chaos back to the right track approach. In this paper, which made several effective methods of anti-jamming software.
1. redundant directives
CPU process is to take instructions from operating code, and then take a few operators. When the PC interference errors, procedures will be from the normal track "flying", when flying to a double-byte instructions, if the instructions for a few moments landed on the operation, as the number-up operation operation code, procedural error will be . If the "fly" to the three-byte instructions, a greater probability of error.
In some key areas were inserted into single-byte instructions, or to be effective single-byte command rewrite directive known as redundancy. Is usually double-byte instructions and orders three bytes inserted after more than two bytes of the NOP. This flew to operate even if the number of flying procedures, the air operations of NOP because of the existence of the directive to avoid being behind the operation as a number of implementation, automatically into the right track.
In addition, the system flows to play an important role in the directive such as RET, RETI, LCALL, LJMP, JC, and other instructions inserted before the two NOP, also could be flying into the right track procedures to ensure that the implementation of these important directives.
2. interception technology
The so-called blocking, is flying the procedure will lead the specified location and then an error handling. Traps are usually software used to block flying procedures. Therefore must be reasonably designed trap, trap in the second to the appropriate location.
1) The design software trap
When flying into the non-process procedures, redundant command will not work. By software traps, interceptors flying procedures, to lead the specified location and then an error handling. Software trap is used to capture the flying process toward reduction of import address 0000 H instructions. Its native code for the 0000020000.
2) the arrangements for traps
Usually in the process of the unused space filled EPROM 0000020000. Finally one should fill 020,000, when flying procedures fell on the area, to automatically orbit. In the user program, and various modules in the margins between the unit can also fill traps command. When using the interference and interruption due to open, in the corresponding interrupt service procedures set up software trap, caught the wrong time can be interrupted. Top of instruction available "RETI", can also be used "LJMP 0000H". If the fault diagnosis procedures and systems since the restoration of the design process reliable, complete with "LJMP 0000H" for the return instructions directly into the fault diagnosis procedures, as soon as possible to deal with failure and recovery procedures of the operation.
Taking into account the capacity of program memory, software trap 1 K space in the general 2-3 can be effectively blocked.
3. the software "watchdog" technology
If out-of-control process into the "cycle of death", usually a "watchdog" technology to process from the "death cycle." By constantly testing procedures cycle running time, if the process cycle time exceeds the maximum running time cycle, the system that a "cycle of death", the need for error handling.
"Watchdog" technology can be hardware, software can be. In industrial applications, serious interference may sometimes be interrupted damage control word, closure of interruption. The system can not regularly, hardware watchdog circuit failure. The software watchdog to be effective in solving such problems.
In practical applications, using ring interrupted surveillance systems. T0 Watchdog timer with T1, with timer T1 surveillance main program, the main program Watchdog T0. This ring used the software "watchdog" has a good anti-jamming performance, greatly improving the system reliability. The need for frequent use of T1 timer serial communications monitoring and control system, the timer T1 can not be interrupted, may be diverted from the serial port to monitor the interruption. Such software "watchdog" monitoring principle is: the main program, T0 interrupted service program, T1 service interruption in the process to establish a running observation variables, assumed to be MWatch, T0Watch, T1Watch, each cycle of a main program, MWatch plus 1 , The same T0, T1 procedures for the implementation of a service interruption, T0Watch, T1Watch plus 1. T0 interruption in the service of process in T1Watch by detecting changes in the determination of whether the normal operation of T1, T1 interruption in the service of process in the detection of changes in the MWatch determine whether the normal operation of the main program, in the main program in T0Watch by detecting changes in normal circumstances determine whether T0 work. If an observation detected abnormal changes in variables, such as an increase should not increase 1, to the error handling procedures for dealing with troubleshooting. Of course, most of the main program cycle, the timer T0 and T1 timing cycle should be completely reasonable to consider.
中文譯文
單片機也被稱為微控制器(Microcontroler),單片機由芯片內僅有CPU的專用處理器發展而來。最早的設計理念是通過將大量外圍設備和CPU集成在一個芯片中,使計算機系統更小,更容易集成。
早期的單片機都是8位或4位的。其中最成功的是INTEL的8031,因為簡單可靠而性能不錯獲得了好評。此后在8031上發展出了MCS51系列單片機系統。基于這一系統的單片機系統直到現在還在廣泛使用。隨著工業控制領域要求的提高,開始出現了16位單片機。90年代后隨著消費電子產品大發展,單片機技術得到了巨大的提高。隨著INTEL i960系列的出現,特別是后來的ARM系列的廣泛應用,32位單片機迅速取代16位單片機的高端地位,并且進入主流市場。而傳統的8位單片機的性能也得到了飛速提高,處理能力比起80年代提高了數百倍。目前,高端的32位單片機主頻已經超過300MHz,性能直追90年代中期的專用處理器。
當代單片機系統已經不再只在裸機環境下開發和使用,大量專用的嵌入式操作系統被廣泛應用在單片機上。作為掌上電腦和手機核心處理的高端單片機甚至可以直接使用專用的Windows和Linux操作系統。 單片機比專用處理器更適合應用于嵌入式系統。事實上單片機是世界上數量最多的計算機。現代人類生活中所用的幾乎每件電子和機械產品中都會集成有單片機。手機、電話、計算器、家用電器、電子玩具、掌上電腦以及鼠標等電腦配件中都配有1-2部單片機。而個人電腦中也會有為數不少的單片機在工作。汽車上一般配備40多部單片機,復雜的工業控制系統上甚至可能有數百臺單片機在同時工作!單片機的數量不僅遠超過PC機和其他計算的綜合,甚至比人類的數量還要多。在單片機應用中,單片機的系統軟件抗干擾和單片機的編程調試一直困擾著初學者。本文就簡單的介紹這兩個問題。
單片機系統軟件抗干擾方法
在提高硬件系統抗干擾能力的同時,軟件抗干擾以其設計靈活、節省硬件資源、可靠性好越來越受到重視。下面以MCS-51單片機系統為例,對微機系統軟件抗干擾方法進行研究。
在工程實踐中,軟件抗干擾研究的內容主要是: 一、消除模擬輸入信號的噪聲(如數字濾波技術);二、程序運行混亂時使程序重入正軌的方法。本文針對后者提出了幾種有效的軟件抗干擾方法。
1.指令冗余
CPU取指令過程是先取操作碼,再取操作數。當PC受干擾出現錯誤,程序便脫離正常軌道“亂飛”,當亂飛到某雙字節指令,若取指令時刻落在操作數上,誤將操作數當作操作碼,程序將出錯。若“飛” 到了三字節指令,出錯機率更大。
在關鍵地方人為插入一些單字節指令,或將有效單字節指令重寫稱為指令冗余。通常是在雙字節指令和三字節指令后插入兩個字節以上的NOP。這樣即使亂飛程序飛到操作數上,由于空操作指令NOP的存在,避免了后面的指令被當作操作數執行,程序自動納入正軌。
此外,對系統流向起重要作用的指令如RET、 RETI、LCALL、LJMP、JC等指令之前插入兩條NOP,也可將亂飛程序納入正軌,確保這些重要指令的執行。
2.攔截技術
所謂攔截,是指將亂飛的程序引向指定位置,再進行出錯處理。通常用軟件陷阱來攔截亂飛的程序。因此先要合理設計陷阱,其次要將陷阱安排在適當的位置。
1)軟件陷阱的設計
當亂飛程序進入非程序區,冗余指令便無法起作用。通過軟件陷阱,攔截亂飛程序,將其引向指定位置,再進行出錯處理。軟件陷阱是指用來將捕獲的亂飛程序引向復位入口地址0000H的指令。其機器碼為0000020000。
2)陷阱的安排
通常在程序中未使用的EPROM空間填0000020000。最后一條應填入020000,當亂飛程序 落到此區,即可自動入軌。在用戶程序區各模塊之間的空余單元也可填入陷阱指令。當使用的中斷因干擾而開放時,在對應的中斷服務程序中設置軟件陷阱,能及時捕獲錯誤的中斷。返回指令可用“RETI”,也可用“LJMP 0000H”。如果故障診斷程序與系統自恢復程序的設計可靠、 完善,用“LJMP 0000H”作返回指令可直接進入故障診斷程序,盡早地處理故障并恢復程序的運行。
考慮到程序存貯器的容量,軟件陷阱一般1K空間有2-3個就可以進行有效攔截。
3.軟件“看門狗”技術
若失控的程序進入“死循環”,通常采用“看門狗”技術使程序脫離“死循環”。通過不斷檢測程序循環運行時間,若發現程序循環時間超過最大循環運行時間,則認為系統陷入“死循環”,需進行出錯處理。
“看門狗”技術可由硬件實現,也可由軟件實現。 在工業應用中,嚴重的干擾有時會破壞中斷方式控制字,關閉中斷。則系統無法定時,硬件看門狗電路失效。而軟件看門狗可有效地解決這類問題。
在實際應用中,采用環形中斷監視系統。用定時器T0監視定時器T1,用定時器T1監視主程序,主程序監視定時器T0。采用這種環形結構的軟件“看門狗”具有良好的抗干擾性能,大大提高了系統可靠性。對于需經常使用T1定時器進行串口通訊的測控系統,則定時器T1不能進行中斷,可改由串口中斷進行監控。這種軟件“看門狗”監視原理是:在主程序、T0中斷服務程序、T1中斷服務程序中各設一運行觀測變量,假設為MWatch、T0Watch 、T1Watch,主程序每循環一次,MWatch加1,同樣T0、T1中斷服務程序執行一次,T0Watch、 T1Watch加1。在T0中斷服務程序中通過檢測T1Watch的變化情況判定T1運行是否正常,在T1中斷服務程序中檢測MWatch的變化情況判定主程序是否正常運行,在主程序中通過檢測T0Watch的變化情況判別T0是否正常工作。若檢測到某觀測變量變化不正常,比如應當加1而未加1,則轉到出錯處理程序作排除故障處理。當然,對主程序最大循環周期、定時器T0和T1定時周期應予以全盤合理考慮。
評論
查看更多