標題:
msp430單片機rc522射頻的程序和與電路圖
[打印本頁]
作者:
yy0115
時間:
2018-11-29 09:42
標題:
msp430單片機rc522射頻的程序和與電路圖
rc522射頻刷卡
0.png
(36.39 KB, 下載次數(shù): 75)
下載附件
2018-12-2 02:10 上傳
0.png
(11.5 KB, 下載次數(shù): 61)
下載附件
2018-12-2 02:10 上傳
單片機源程序如下:
#include <msp430x41x.h>
#include "main.h"
#include "mfrc522.h"
#pragma memory = constseg(TAB)
unsigned char data1[16] = {0x12,0x34,0x56,0x78,0xED,0xCB,0xA9,0x87,0x12,0x34,0x56,0x78,0x01,0xFE,0x01,0xFE};
//M1卡的某一塊寫為如下格式,則該塊為錢包,可接收扣款和充值命令
//4字節(jié)金額(低字節(jié)在前)+4字節(jié)金額取反+4字節(jié)金額+1字節(jié)塊地址+1字節(jié)塊地址取反+1字節(jié)塊地址+1字節(jié)塊地址取反
unsigned char data2[4] = {0x12,0,0,0};
unsigned char DefaultKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
#pragma memory=default
unsigned char g_ucTempbuf[20];
void main(void)
{
unsigned char status;
InitializeSystem();
PcdReset();
PcdAntennaOff();
PcdAntennaOn();
while ( 1 )
{
status = PcdRequest(PICC_REQALL, g_ucTempbuf);
if (status != MI_OK)
{
LED_GREEN_OFF;
continue;
}
LED_GREEN_ON; //檢測到有卡存在
status = PcdAnticoll(g_ucTempbuf);
if (status != MI_OK)
{ continue; }
status = PcdSelect(g_ucTempbuf);
if (status != MI_OK)
{ continue; }
status = PcdAuthState(PICC_AUTHENT1A, 1, DefaultKey, g_ucTempbuf);
if (status != MI_OK)
{ continue; }
status = PcdWrite(1, data1);
if (status != MI_OK)
{ continue; }
status = PcdValue(PICC_DECREMENT,1,data2);
if (status != MI_OK)
{ continue; }
status = PcdBakValue(1, 2);
if (status != MI_OK)
{ continue; }
status = PcdRead(2, g_ucTempbuf);
if (status != MI_OK)
{ continue; }
PcdHalt();
}
}
/////////////////////////////////////////////////////////////////////
//功能:系統(tǒng)初始化
/////////////////////////////////////////////////////////////////////
void InitializeSystem(void)
{
WDTCTL = WDTPW + WDTHOLD; //Stop watchdog timer
_DINT();
P1DIR = 0xE8;
P1OUT = 0xFF;
P6DIR = 0x08;
P6OUT = 0xFF;
}
復制代碼
所有資料51hei提供下載:
51單片機rc522 射頻的程序和與電路圖.rar
(2.66 MB, 下載次數(shù): 25)
2018-11-29 09:41 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1