91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

51單片機(jī)125Khz ID卡讀卡程序 51單片機(jī) 125Khz ID卡 C程序 解曼徹斯特碼

資源截圖

代碼片段和文件信息

#include?“..\config.h“

/*
manchester編碼方式:0為10?1為01,如果與其相反則需要做相應(yīng)的修改。
適用于125KHz非接觸式ID卡,EM4100兼容格式ID卡(64bits?Manchester編碼)
MCU:stc12c54xx
crystal:11.0592M

使用資源:外部中斷0(INT0)+PCA0
*/


/***********讀卡變量定義*************************/
//uint8?tcount????????;//?定時中斷計數(shù)
//uint8?count?????????;//接收數(shù)據(jù)位數(shù)計數(shù)
uint8?count_data;?????//
//uint8?t_count???????;//獲得數(shù)據(jù)及校驗變量。
uint16?wait_jump=500;
uint8?xdata?temp_buf[16]?;//128個Machester位?55個數(shù)據(jù)位?緩沖區(qū)。
uint8?xdata?effectdata[5]?;//5個數(shù)據(jù)緩沖區(qū)。相當(dāng)于模塊串行讀的10?Bytes?數(shù)據(jù)。
uint8?xdata?temp_buf_check[16];



void?init_dev(void)
{
AUXR=0x80;????//T0不分頻
WAKE_CLK0|=0x01;
CMOD?=?0x80;?//PCA?在空閑模式下停止?PCA?計數(shù)器工作
CCON?=?0x00;?//;CF?=?0,清0?PCA?計數(shù)器溢出中斷請求標(biāo)志位
CCAP0L=Channe256uS_L;//給?PCA?模塊0?的?CCAP0L?置初值
CCAP0H=Channe256uS_H;
CCAPM0=0X49;?
CCAP1L=0xff;//給?PCA?模塊0?的?CCAP0L?置初值
CCAP1H=0xb3;
CCAPM1=0;?

SCON=0x50;//串口工作在方式1,允許接收。
TMOD?=?0x22?;?//定時器1工作在方式2?for?generator?baud?rate
TH1=0xFD;//11.0592M?baud?rate//串口用于調(diào)試方便,波特率9600
TL1=0xFD;
TH0??=?212;??????????//定時?4us
TL0??=?212;
//PT0=1;
IPH=0x19;
IP=0x59;
//ET1=1;
TR0=1;
TR1=1;?
//ES=1;
count_data?=?0?;
EX0?=?1?;
CL?=?0x00;?//清0?PCA?計數(shù)器
CH?=?0x00;?????
//EPCA_LVD=1;//開?PCA?中斷和?LVD(低壓檢測)中斷共享的總中斷控制位
CR=1;//?啟動?PCA?計數(shù)器(CHCL)計數(shù)
EA?=?1?;//??????開總中斷
}

void??sent(uint8??i)
{?
SBUF=i;
while(!TI);
TI=0;
}?//這是串口發(fā)送程序



/*********************************************

函數(shù)名:Timer0_Serve

功能:??定時器0中斷

參數(shù):??無

*********************************************/

/*void?Timer0_Serve()?interrupt?1??//定時0中斷

{????????

?????????//RFID_PCM=(!RFID_PCM);


}*/


/*********************************************

函數(shù)名:PCA0_Serve

功能:?定時器1中斷

參數(shù):?無

*********************************************/

void?PCA_Serve()?interrupt?6?//定時0中斷

{
uint8?i;
uint16?led_count_2;
uint8?door_open_time_i;
//test_pin=~test_pin;
wait_jump=400;
if?(store_card_flag||store_card_21flag||store_maincard_flag||delete_card_flag)
{
led_count_2++;
check_count++;
if?(led_count_2==100){led_count_2=0;led=~led;}
//if?(ir_key_xing){led=0;ir_key_xing=0;store_card_flag=store_maincard_flag=delete_card_flag=0;}
if?(check_count==6000)
{for?(i=0;i<4;i++){pre_data[i]=0x00;}
led=0;check_count=0;store_card_flag=store_card_21flag=store_maincard_flag=delete_card_flag=0;}
}

if?(CCF1)//50ms中斷
{
CL?=?0x00;?//清0?PCA?計數(shù)器
CH?=?0x00;????
CCF1=0;//清0?PCA?模塊0中斷請求標(biāo)志位?
led_count++;
if?(check_time){check_count++;}
if?(check_count==200){check_count=0;check_time=0;}//門鎖輸入密碼的超時10s退出
if?(led_en&&led_count==5){led_count=0;led=~led;}//250ms閃一次燈
}
if?(CCF0)//128us中斷
{
if?(door_open||alarm_start)
{
door_open_time_i++;
if?(door_open_time_i==100){door_open_time_i=0;door_open_time_j++;}
if?((door_open_time_j>=byte_read(0x0005))&&door_open&&(door_mag==0))//刷卡不開門超時關(guān)門
{door_open_time_i=0;door_open_time_j=0;lock_open=1;}
if?((door_open_time_j>=byte_read(0x0005))&&door_open&

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????11938??2011-12-04?14:18??rfid\rfid.c

?????文件???????1520??2011-12-04?14:01??rfid\rfid.h

?????目錄??????????0??2011-11-26?15:33??rfid

-----------?---------??----------?-----??----

????????????????13458????????????????????3


評論

共有 條評論