What is the method of realizing interrupt counting in C language?
This article introduces the relevant knowledge of "what is the method of realizing interrupt counting in C language". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
#include void init(){ //Because the interrupt TF1 will be automatically cleared by hardware, it can be left alone here. P1 = 0xff; //Set the light off TMOD = 0x5f; //Set Counter 1 to work in Counter Mode, Mode 1 TH1 = 0xff; TL1 = 0xfb; TR1 = 1; //Counter 1 available EA = 1; //interrupt allowed ET1 =1; //Allow counter 1 interrupt}void main(){ init(); while(1){}}void yetinterrupt() interrupt 3{ P1 = 0xfe; //Set light on while(TL1 == 0x00) {} //Wait for the 6th press init();}
assembly language edition
ORG 0000HLJMP MAINORG 001BHLJMP IR_T1MAIN: SETB P1.O ACALL INIT_T1WAIT: JMP WAIT ; loop wait; initialize counter 1INIT_T1: MOV TMOD, #50H ; Set T1 working mode 1 count MOV TH1, #0FFH MOV TL1, #0FBH SETB EA SETB ET1 SET TR1 RET; Interrupt register service IR_T1: CLR P1.0LOOP: MOV A, TL1 JZ LOOP ; A register equals 0 jump SETB P1.0 LCALL INIT_T1 RETIEND"C language implementation interrupt counting method is what" the content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!