首页资源分类嵌入式系统其他 > STC单片机 源码

STC单片机 源码

已有 445010个资源

下载专区

上传者其他资源

    文档信息举报收藏

    标    签:STC

    分    享:

    文档简介

    STC 单片机做的计数器程序

    文档预览

    /******************************************************************* * Copyright (c) 2013_11_16 ,ARK-co.ltd * All rights reserved. * MCU : STC11F56XE; 56K flash SRAM 256 +1024 eeprom 5k * OperateOS : StateOS * Description : ARK counter * Author(s) : mabugang * version : 0.01 * Modify date : *******************************************************************/ #include "stc_new_8051.h" #include "type.h" #include "stdio.h" #include "eeprom.h"//for eeprom #include "wdt.h" // for watchdog #include "uart.h" // for com0 #include "zlg7289.h" // for keyboard #include "timer.h" //for timer0 #include "frequ.h" // 电流传感 P16 设置P17 加紧打开信号:P10 - P15 // for cpu id uchar idata *CPU_ID ; // for compiler Version uchar code CompilerDate[]=__DATE__; uchar code CompilerTime[]=__TIME__; // for out1&2 sbit out1 = P4^2 ; // 输出1信号 1 = 外部无效 0 = 外部有效 sbit out2 = P4^3 ; // 输出2信号 //SYS status uchar sys_status = 0 ; // 0 - 正常状态 1 = 设置状态 2 补焊状态 uchar config_status = 0 ; // 0 - HLP1 ... 配置状态 uchar rotate_status = 0 ; uchar rotate_status1 = 0 ; // for keyvalue uchar key_value = 0; // for 夹具 uchar jiajin_value = 0XFF; bit jiajin_flag = 0; unsigned char jiajin_ctr = 0 ; bit jiajin_esc_flag = 0; unsigned char jiajin_esc_ctr = 0 ; bit jiajin_key = 0; uchar open_value =0XFF ; bit open_flag = 0; unsigned char open_ctr = 0; bit open_esc_flag = 0; unsigned char open_esc_ctr = 0; bit open_key = 0; uchar jiajin_b_value = 0XFF; bit jiajin_b_flag = 0; unsigned char jiajin_b_ctr = 0 ; bit jiajin_b_esc_flag = 0; unsigned char jiajin_b_esc_ctr = 0; bit jiajin_b_key = 0; bit open_b_key = 0 ; uchar pos_value = 0XFF ;// 左右位置 //first power bit power_on = 0 ;// 初次上电 /******************************************************************************* function : cpu _ init *******************************************************************************/ void CPU_Initilized(void) { uchar i ; EA = 0; /* init timer0 */ Timer0_Init() ; /* init uart0 */ Uart0_Init() ; /* init wdt */ Wdt_init ; /* all interrupt */ EA = 1; dbg_printf("\r\nStateOS Compiler DATE = %s TIME = %s \r\n",CompilerDate,CompilerTime) ; dbg_printf("CPU initilized ...!\r\n") ; //cpu id CPU_ID = 0XF1 ; dbg_printf("CPU ID = ") ; for(i=0 ; i<7 ;i++) { dbg_printf("%bx ",*(CPU_ID)) ; CPU_ID++ ; } dbg_printf("\r\n") ; // reset ZLG7289 Write_ZLG7289_CMD(1,CMD_RESET) ; Write_ZLG7289_CMD(2,CMD_RESET) ; dbg_printf("ZLG7289 initilized ...!\r\n") ; } /******************************************************************************* function : Clamp status _init *******************************************************************************/ void Clamp_Initilized(void) { jiajin_value = 0XFF ; open_value = 0XFF ; jiajin_b_value = 0XFF ; pos_value =0XFF ; //0 -0x01 1 0x02 2 0x04 3 0x08 4 0x10 5 0x20 if( single_mode == 0) { if(welding_mode == 0) { jiajin_value = 1<<(weld_a_press_pins-1) ; dbg_printf("clamp welding_mode = %bd jiajin value= %bx ...!\r\n",welding_mode,jiajin_value) ; } else if(welding_mode == 1) { if( switch_mode == 0) { jiajin_value = 1<<(weld_a_press_pins-1) ; } else if( switch_mode == 1) { jiajin_value = 1<<(weld_a_press_pins-1) ; jiajin_b_value = 1<<(weld_b_press_pins-1) ; jiajin_b_value = jiajin_b_value + 1<<(weld_b_press_ext_pins-1) ; } else if( switch_mode == 2) { jiajin_value = 1<<(weld_a_press_pins-1) ; jiajin_value = jiajin_value + 1<<(weld_a_press_ext_pins-1) ; jiajin_b_value = 1<<(weld_b_press_pins-1) ; } else { jiajin_value = 1<<(weld_a_press_pins-1) ; jiajin_value = jiajin_value + 1<<(weld_a_press_ext_pins-1) ; jiajin_b_value = 1<<(weld_b_press_pins-1) ; jiajin_b_value = jiajin_b_value + 1<<(weld_b_press_ext_pins-1) ; } dbg_printf("clamp welding_mode = %bd jiajin value= %bx jiajin_b value= %bx...!\r\n",welding_mode,jiajin_value,jiajin_b_value) ; } else { jiajin_value = 1<<(weld_a_press_pins-1) ; jiajin_b_value = 1<<(weld_b_press_pins-1) ; pos_value = 1<<(weld_b_press_ext_pins-1) ; dbg_printf("clamp welding_mode = %bd jiajin value= %bx jiajin_b value= %bx pos_value = %bx ...!\r\n",welding_mode,jiajin_value,jiajin_b_value,pos_value) ; } } else if( single_mode == 1) { if(welding_mode == 0) { jiajin_value = 1<<(weld_a_press_pins-1) ; open_value = 1<<(weld_a_press_ext_pins-1) ; dbg_printf("clamp welding_mode = %bd jiajin value= %bx open_value= %bx...!\r\n",welding_mode,jiajin_value,open_value) ; } } } /******************************************************************************* normal status *******************************************************************************/ void Normal_Key_handler(void) { key_value = read_ZLG7289_key(); switch(key_value) { case 0: //补焊 LED_NoWield_Display(1) ;//补焊指示灯点亮 // out1 = (bit)weld_repairs_out1 ; out2 = (bit)weld_repairs_out2 ; // sys_status = 2 ; break ; case 1: //B点清零 if(work_mode == 2) { if(clear_point_fun == 0) now_b_points = 0 ; else { if(now_b_points >= default_b_points) now_b_points = 0 ; } out2 = clear_point_out2 ; } break ; case 2: //A点清零 if(work_mode == 1) { if(ctr_handler_clear_point == 0) now_a_points = 0 ; else { if(now_a_points >= default_a_points) now_a_points = 0 ; } LED_A_Now_Display() ; } else if(work_mode == 2) { if(clear_point_fun == 0) now_a_points = 0 ; else { if(now_a_points >= default_a_points) now_a_points = 0 ; } out1 = clear_point_out1 ; } break ; case 3: //工件清零 Total_Product = 0 ; Total_Product_Display() ; Save_Product_To_EEprom() ; break ; case 6: // 设置 sys_status = 1 ; config_status = 1 ; led_pos = 0 ; Config_Display_Initilized(config_status); LED_Display_Blink(led_pos+1) ; LED_Work_Display(2) ;// Config status out1 = out2 = 1 ; //disable out break ; } } void Normal_Sys_Status(void) { if(work_mode == 0) //计数器 计数模式 自动复位 仅仅计数 { if(frequ == 1) { frequ = 0 ; now_a_points++ ; LED_A_Now_Display() ; if(now_a_points >= default_a_points) { now_a_points = 0 ; Total_Product++ ; Total_Product_Display() ; Save_Product_To_EEprom() ; } dbg_printf("work_mode = %bd now_a_points= %bd ...!\r\n",work_mode,now_a_points) ; } } else if(work_mode == 1) //计数模式 手动复位 { if(now_a_points < default_a_points) { out1 = (bit)ctr_handler_sout ; } else out1 = (bit)ctr_handler_bout ; if(frequ == 1) { frequ = 0 ; now_a_points++ ; LED_A_Now_Display() ; if ( (now_a_points >= default_a_points)&& ( now_a_points / default_a_points > 0 ) ) { Total_Product++ ; Total_Product_Display() ; Save_Product_To_EEprom() ; } dbg_printf("work_mode = %bd now_a_points= %bd ...!\r\n",work_mode,now_a_points) ; } } else if(work_mode == 2) // 计数器控制模式 { if(welding_mode == 0) //一次焊接 { //jiajin if( (jiajin_key == 1) && (rotate_status == 0) ) { jiajin_key = 0 ; open_key = 0 ; LED_A_Status_Display(1) ; rotate_status = 1 ; power_on = 1 ; out1 =(bit) weld_a_press_out1 ; out2 =(bit) weld_a_press_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } else if( (jiajin_key == 1) && (rotate_status == 2) ) { jiajin_key = 0 ; rotate_status = 3 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } // open if( (open_key == 1)&& (power_on == 0))// 初次上电 // 双点模式有可能已经存在加紧 { open_key = 0 ; jiajin_key = 0 ; power_on = 1 ; out1 = (bit)weld_a_open_ok_out1 ; out2 = (bit)weld_a_open_ok_out2 ; } else { if( (open_key == 1) && ((rotate_status == 1)|| (rotate_status == 3)) ) { open_key = 0 ; jiajin_key = 0 ; if(now_a_points >= default_a_points) { now_a_points = 0 ; LED_A_Now_Display() ; LED_A_Status_Display(0) ; Total_Product++ ; Total_Product_Display() ; Save_Product_To_EEprom() ; rotate_status = 0 ; out1 = (bit)weld_a_open_ok_out1 ; out2 = (bit)weld_a_open_ok_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } else { LED_A_Status_Display(2) ; rotate_status = 2 ; out1 = (bit)weld_a_open_fail_out1 ; out2 = (bit)weld_a_open_fail_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } } } switch(rotate_status) { case 1: case 3: if(frequ == 1) { frequ = 0 ; now_a_points++ ; LED_A_Now_Display() ; if(now_a_points >= default_a_points) { LED_A_Status_Display(3) ; } } break ; default: break ; } } else if(welding_mode == 1)//两次焊接 { //jiajin1 if( (jiajin_key == 1) && (rotate_status == 0) ) { jiajin_key = 0 ; open_key = 0 ; LED_A_Status_Display(1) ; rotate_status = 1 ; power_on = 1 ; out1 =(bit) weld_a_press_out1 ; out2 =(bit) weld_a_press_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } else if( (jiajin_key == 1) && (rotate_status == 2) ) { jiajin_key = 0 ; open_key = 0 ; rotate_status = 3 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } // open1 if( (open_key == 1) && ((rotate_status == 1)|| (rotate_status == 3)) ) { open_key = 0 ; if(now_a_points >= default_a_points) { now_a_points = 0 ; now_b_points = 0 ; LED_A_Now_Display() ; LED_A_Status_Display(0) ; if(product_mode == 0 ) { Total_Product++ ; Total_Product_Display() ; Save_Product_To_EEprom() ; } rotate_status = 4 ; out1 = (bit)weld_a_open_ok_out1 ; out2 = (bit)weld_a_open_ok_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; if(switch_mode == 0) LED_B_Status_Display(1) ; } else { LED_A_Status_Display(2) ; rotate_status = 2 ; out1 = (bit)weld_a_open_fail_out1 ; out2 = (bit)weld_a_open_fail_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } } // jiajin b if( (jiajin_b_key == 1) && (rotate_status == 4) ) { jiajin_b_key = 0 ; open_b_key = 0 ; LED_B_Status_Display(1) ; rotate_status = 5 ; out1 =(bit) weld_b_press_out1 ; out2 =(bit) weld_b_press_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } else if( (jiajin_b_key == 1) && (rotate_status == 6) ) { jiajin_b_key = 0 ; open_b_key = 0 ; rotate_status = 7 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } // open b if( (open_b_key == 1) && ((rotate_status == 5)|| (rotate_status == 7)) ) { open_b_key = 0 ; if(now_b_points >= default_b_points) { now_b_points = 0 ; LED_B_Now_Display() ; LED_B_Status_Display(0) ; Total_Product++ ; Total_Product_Display() ; Save_Product_To_EEprom() ; rotate_status = 0 ; out1 = (bit)weld_b_open_ok_out1 ; out2 = (bit)weld_b_open_ok_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } else { LED_B_Status_Display(2) ; rotate_status = 7 ; out1 = (bit)weld_b_open_fail_out1 ; out2 = (bit)weld_b_open_fail_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } } switch(rotate_status) { case 1: case 3: if(frequ == 1) { frequ = 0 ; now_a_points++ ; LED_A_Now_Display() ; if(now_a_points >= default_a_points) { LED_A_Status_Display(3) ; } } break ; case 5: case 7: if(frequ == 1) { frequ = 0 ; now_b_points++ ; LED_B_Now_Display() ; if(now_b_points >= default_b_points) { LED_B_Status_Display(3) ; } } break ; case 4: if(frequ == 1) { frequ = 0 ; now_b_points++ ; LED_B_Now_Display() ; if(now_b_points >= default_b_points) { LED_B_Status_Display(3) ; rotate_status = 0 ; } } break ; default: break ; } } else if(welding_mode == 2)//左右焊接 { //jiajin1 if( (jiajin_key == 1) && (rotate_status == 0) ) { jiajin_key = 0 ; open_key = 0 ; LED_A_Status_Display(1) ; rotate_status = 1 ; out1 =(bit) weld_a_press_out1 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } else if( (jiajin_key == 1) && (rotate_status == 2) ) { jiajin_key = 0 ; open_key = 0 ; rotate_status = 3 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } // open1 if( (open_key == 1) && ((rotate_status == 1)|| (rotate_status == 3)) ) { open_key = 0 ; if(now_a_points >= default_a_points) { now_a_points = 0 ; LED_A_Now_Display() ; LED_A_Status_Display(0) ; Total_Product++ ; Total_Product_Display() ; Save_Product_To_EEprom() ; rotate_status = 0 ; out1 = (bit)weld_a_open_ok_out1 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } else { LED_A_Status_Display(2) ; rotate_status = 2 ; out1 = (bit)weld_a_open_fail_out1 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status =%bd ...!\r\n",work_mode,welding_mode,rotate_status) ; } } switch(rotate_status) { case 1: case 3: if(frequ == 1) { frequ = 0 ; now_a_points++ ; LED_A_Now_Display() ; if(now_a_points >= default_a_points) { LED_A_Status_Display(3) ; } } break ; default: break ; } // jiajin b if( (jiajin_b_key == 1) && (rotate_status1 == 0) ) { jiajin_b_key = 0 ; open_b_key = 0 ; LED_B_Status_Display(1) ; rotate_status1 = 1 ; out2 =(bit) weld_b_press_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status1 =%bd ...!\r\n",work_mode,welding_mode,rotate_status1) ; } else if( (jiajin_b_key == 1) && (rotate_status1 == 2) ) { jiajin_b_key = 0 ; open_b_key = 0 ; rotate_status = 3 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status1 =%bd ...!\r\n",work_mode,welding_mode,rotate_status1) ; } // open b if( (open_b_key == 1) && ((rotate_status == 1)|| (rotate_status == 3)) ) { open_b_key = 0 ; if(now_b_points >= default_b_points) { now_b_points = 0 ; LED_B_Now_Display() ; LED_B_Status_Display(0) ; Total_Product++ ; Total_Product_Display() ; Save_Product_To_EEprom() ; rotate_status1 = 0 ; out2 = (bit)weld_b_open_ok_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status1 =%bd ...!\r\n",work_mode,welding_mode,rotate_status1) ; } else { LED_B_Status_Display(2) ; rotate_status = 2 ; out2 = (bit)weld_b_open_fail_out2 ; dbg_printf("work_mode = %bd welding_mode= %bd rotate_status1 =%bd ...!\r\n",work_mode,welding_mode,rotate_status1) ; } } switch(rotate_status1) { case 1: case 3: if(frequ == 1) { frequ = 0 ; if( (P1&pos_value) == 0X00 ) { now_b_points++ ; LED_B_Now_Display() ; if(now_b_points >= default_b_points) { LED_B_Status_Display(3) ; } } } break ; default: break ; } } else dbg_printf("Do not Support this mode welding_mode = %bd...!\r\n", welding_mode ) ; } else { dbg_printf("Do not Support this mode work_mode = %bd...!\r\n", work_mode ) ; } } /******************************************************************************* Config status *******************************************************************************/ void Config_Key_handler(void) { key_value = read_ZLG7289_key(); if( key_value == 4 )//修改数字 { led_buffer[led_pos]++ ; if(led_buffer[led_pos] > 9) { led_buffer[led_pos] = 0 ; } Config_Display_Initilized(0) ; } else if( key_value == 5 )//移位 { led_pos++ ; if( led_pos > 8) { led_pos = 0 ; } LED_Display_Blink(led_pos+1) ; } else if( key_value == 6 )//设置 { Save_LED_Buffer(config_status) ; Save_Para_To_EEprom() ; if(config_status < 9) { config_status++ ; led_pos = 0 ; Config_Display_Initilized(config_status); LED_Display_Blink(led_pos+1) ; } else { sys_status = 0 ; config_status = 0 ; now_a_points = 0 ; now_b_points = 0 ; LED_Display_Blink(0) ; //display LED_Work_Display(1) ;//工作指示灯 // Total_Product_Display() ; // a LED_A_Default_Display() ; LED_A_Now_Display() ; // B LED_B_Default_Display() ; LED_B_Now_Display() ; // Clamp_Initilized(); } } } /******************************************************************************* welding repairs *******************************************************************************/ void Welding_repairs_Key_handler(void) { key_value = read_ZLG7289_key(); switch(key_value) { case 0: //补焊 sys_status = 0 ; config_status = 0 ; rotate_status = 0 ; rotate_status1 = 0 ; now_a_points = 0 ; now_b_points = 0 ; jiajin_key = 0 ; open_key = 0 ; jiajin_b_key = 0 ; open_b_key = 0 ; //display LED_NoWield_Display(0) ;//补焊指示灯熄灭 // Total_Product_Display() ; // a LED_A_Default_Display() ; LED_A_Now_Display() ; // B LED_B_Default_Display() ; LED_B_Now_Display() ; // LED_A_Status_Display(0) ; LED_B_Status_Display(0) ; break ; } } void Welding_repairs_Sys_Status(void) { if(weld_repairs_fun == 0) { } else { if( open_key == 1) { sys_status = 0 ; config_status = 0 ; rotate_status = 0 ; rotate_status1 = 0 ; now_a_points = 0 ; now_b_points = 0 ; jiajin_key = 0 ; open_key = 0 ; jiajin_b_key = 0 ; open_b_key = 0 ; //display LED_NoWield_Display(0) ;//补焊指示灯熄灭 // Total_Product_Display() ; // a LED_A_Default_Display() ; LED_A_Now_Display() ; // B LED_B_Default_Display() ; LED_B_Now_Display() ; // LED_A_Status_Display(0) ; LED_B_Status_Display(0) ; } } } /******************************************************************************* main.c *******************************************************************************/ void main(void) { // cpu initilized CPU_Initilized() ; // read parameters Reader_Para_From_EEprom(); // Clamp_Initilized(); // LED_Work_Display(1) ;//工作指示灯 // Total_Product_Display() ; // a LED_A_Default_Display() ; LED_A_Now_Display() ; // B LED_B_Default_Display() ; LED_B_Now_Display() ; /* loop infinte */ dbg_printf("while main function ...!\r\n") ; while(1) { /* reset wdt */ Wdt_reset ; switch( sys_status ) { case 0 : Normal_Key_handler() ; Normal_Sys_Status() ; break ; case 1: Config_Key_handler() ; break ; case 2: Welding_repairs_Key_handler(); Welding_repairs_Sys_Status() ; break; default: break ; } } } /******************************************************************************* * Function Name : timer0 isr *******************************************************************************/ void timer0_ISR() interrupt 1 using 2 { TH0 = 0xfc; TL0 = 0x66; TF0 = 0; //1ms // zlg7289 int2 ZLG7289_Timer0_Handler() ; //电流信号 P16 FREQU_Timer0_Handler(); //夹具状态 if( ( (P1 & jiajin_value) == 0x00 ) && (jiajin_flag==0) && (jiajin_esc_flag==0) ) jiajin_flag = 1 ; // if(jiajin_flag == 1) jiajin_ctr ++ ; // check ctr if( (jiajin_ctr > 5 ) && (jiajin_ctr < Valid_Cycle * 20) ) { if( (P1 & jiajin_value) == 0x00 ) { jiajin_key = 1; jiajin_esc_flag = 1 ; jiajin_flag = 0 ; jiajin_ctr = 0 ; } } else if (jiajin_ctr >= Valid_Cycle * 20) { jiajin_flag = 0 ; jiajin_ctr = 0 ; } // if(jiajin_esc_flag == 1) { if( (P1 & jiajin_value) == jiajin_value ) jiajin_esc_ctr ++ ; else jiajin_esc_ctr = 0 ; if(jiajin_esc_ctr >= InValid_Cycle * 20 ) { jiajin_esc_ctr = 0; jiajin_esc_flag = 0 ; if( single_mode == 1) open_key = 1 ; } } if( single_mode == 2) { if( ( (P1 & open_value) == 0x00 ) && (open_flag==0) && (open_esc_flag==0) ) open_flag = 1 ; // open if(open_flag == 1) open_ctr ++ ; // check ctr if( (open_ctr > 5 ) && (open_ctr < Valid_Cycle * 20) ) { if( (P1 & open_value) == 0x00 ) { open_key = 1; open_esc_flag = 1 ; open_flag = 0 ; open_ctr = 0 ; } } else if (open_ctr >= Valid_Cycle * 20) { open_flag = 0 ; open_ctr = 0 ; } // if(open_esc_flag == 1) { if( (P1 & open_value) == open_value ) open_esc_ctr ++ ; else open_esc_ctr = 0 ; if(open_esc_ctr >= InValid_Cycle * 20 ) { open_esc_ctr = 0; open_esc_flag = 0 ; } } } if( (welding_mode == 1) ||(welding_mode == 2) ) { if( ( (P1 & jiajin_b_value) == 0x00 ) && (jiajin_b_flag==0) && (jiajin_b_esc_flag==0) ) jiajin_b_flag = 1 ; if(jiajin_b_flag == 1) jiajin_b_ctr ++ ; // check ctr if( (jiajin_b_ctr > 5 ) && (jiajin_b_ctr < Valid_Cycle * 20) ) { if( (P1 & jiajin_b_value) == 0x00 ) { jiajin_b_key = 1; jiajin_b_esc_flag = 1 ; jiajin_b_flag = 0 ; jiajin_b_ctr = 0 ; } } else if (jiajin_b_ctr >= Valid_Cycle * 20) { jiajin_b_flag = 0 ; jiajin_b_ctr = 0 ; } // if(jiajin_b_esc_flag == 1) { if( (P1 & jiajin_b_value) == jiajin_b_value ) jiajin_b_esc_ctr ++ ; else jiajin_b_esc_ctr = 0 ; if(jiajin_b_esc_ctr >= InValid_Cycle * 20 ) { jiajin_b_esc_ctr = 0; jiajin_b_esc_flag = 0 ; open_b_key = 1 ; } } } }

    Top_arrow
    回到顶部
    EEWORLD下载中心所有资源均来自网友分享,如有侵权,请发送举报邮件到客服邮箱bbs_service@eeworld.com.cn 或通过站内短信息或QQ:273568022联系管理员 高员外,我们会尽快处理。