文档详情

51单片机外部中断的C51编程(国外英文资料).doc

发布:2017-06-08约1.1万字共18页下载文档
文本预览下载声明
51单片机外部中断的C51编程(国外英文资料) Knowledge: The 5 major source of the single chip machine: serial port interrupts, time interrupts 1, external interruption 1, time interrupts 0, external interrupt 0; The number of interrupts: the serial port interruption is 4, the time interrupts 1 is 3, the external interrupts 1 is 2, the time interrupts 0 is 1, the external interrupt 0 is 0; The priority of the interrupt source: in the order of the above sequence, the number of serial port interrupts is the lowest and the external interrupts 0 is the highest. 4, using external interrupts 0 and 1, you must set the TCON register to set its trigger mode whether it is a low level trigger (0) or a drop down trigger (1). Before using the Internet explorer register, the total interruption and interruption must be opened. / / external interrupt basic routines - 1 (uninterruptable, keyboard scan for general port scanning) / / this is a specially arranged routine for comparison with the use of an external interrupt routine 2 / / use a button to control the light of a lamp, start not to light, click on the light, then click off, then click again... # include reg52. H Sbit k1 = P3 ^ 2; Sbit led = P2 ^ 7; Void delay_ms (unsigned int XMS); / / ms delay subroutines Void key_scan (); / / declare keyboard scan function / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Void main () { Led = 1; / / electricity is initialized, led lights are not bright While (1) { Key_scan (); Delay_ms (3000); } } / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Void delay_ms (unsigned int XMS) / / ms delay subroutine {unsigned int x, y; (x = XMS; x, , 0; x --) For (y = 130; y = 130; y; ; y --); } / / -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Void key_scan () / / keyboard scan function {if (k1 = = 0) / / has the key pre
显示全部
相似文档