控制/MCU
嵌入式操作系统 /
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定时周期应予以全盘合理考虑。
全部0条评论
快来发表一下你的评论吧 !