RC500要在串口显示卡的序列号,为什么就是显示不出来呢?
时间:10-02
整理:3721RD
点击:
最近在玩rc500模块要在串口显示卡的序列号,为什么就是显示不出来呢,望大神点播
#define M500_GLOBALS
#include "INTRINS.H"
#include "stdio.h"
#include "string.h"
#include "STC_NEW_8051.h"
#include "main.h"
#include "Mfreg500.h"
#include "MfErrNo.h"
#include "M500AuC.h"
sbit SPEAKER = P2^4;
sbit LED2 = P1^0;
sbit LED3 = P1^1;
extern unsigned char idata MLastSelectedSnr[4];
extern unsigned char idata RevBuffer[30]; //RevBuffer是接收和发送缓冲区
extern unsigned char data SerBuffer[20]; //SerBuffer是进行卡的其他操作所使用的临时缓冲区
extern bit CmdValid;
//蜂鸣器
void Beep(unsigned int value)
{
SPEAKER=1;
delay_10ms(value);
SPEAKER=0;
}
//==============================================
//串行口1初始化函数
void SCI1_Init()
{ //在11.0592MHz晶振下,设置串行口9600数据传输率,方式3
PCON |=0x80; //不可位寻址
//PCON的最高位是波特率加倍位(SMOD位),PCON=0x80时波特率加倍。
SCON=0x50;
TMOD=0x21;
TL1=BAUD_9600;//0xFD;
TH1=TL1;
TR1=1;
ES = 1;
}
void UART_send_byte(uint dat) //发送一个字节
{
SBUF=dat;
while(TI==0);
TI=0;
}
void display()
{
UART_send_byte(MLastSelectedSnr[0]);
UART_send_byte(MLastSelectedSnr[1]);
UART_send_byte(MLastSelectedSnr[2]);
UART_send_byte(MLastSelectedSnr[3]);
}
/////////////////////////////////////////////////////////////////////
// 主函数
/////////////////////////////////////////////////////////////////////
void main(void)
{
EA=0; //禁止中断,防止MFRC500未初始化
SCI1_Init();
Mfrc500Init();
EA=1;
while (1)
{
if( M500PiccCommonRequest(0x26,&RevBuffer[2])==MI_OK)
{
M500PiccCommonRequest(0x26,&RevBuffer[2]);
delay_50us(50);
M500PiccCascAnticoll(0,MLastSelectedSnr);
if(M500PiccCascAnticoll(0,MLastSelectedSnr)==MI_OK)
{
display();
}
else
{
M500PiccCascAnticoll(0,MLastSelectedSnr);
}
}
else
{
M500PiccCommonRequest(0x26,&RevBuffer[2]);
}
}
}
#define M500_GLOBALS
#include "INTRINS.H"
#include "stdio.h"
#include "string.h"
#include "STC_NEW_8051.h"
#include "main.h"
#include "Mfreg500.h"
#include "MfErrNo.h"
#include "M500AuC.h"
sbit SPEAKER = P2^4;
sbit LED2 = P1^0;
sbit LED3 = P1^1;
extern unsigned char idata MLastSelectedSnr[4];
extern unsigned char idata RevBuffer[30]; //RevBuffer是接收和发送缓冲区
extern unsigned char data SerBuffer[20]; //SerBuffer是进行卡的其他操作所使用的临时缓冲区
extern bit CmdValid;
//蜂鸣器
void Beep(unsigned int value)
{
SPEAKER=1;
delay_10ms(value);
SPEAKER=0;
}
//==============================================
//串行口1初始化函数
void SCI1_Init()
{ //在11.0592MHz晶振下,设置串行口9600数据传输率,方式3
PCON |=0x80; //不可位寻址
//PCON的最高位是波特率加倍位(SMOD位),PCON=0x80时波特率加倍。
SCON=0x50;
TMOD=0x21;
TL1=BAUD_9600;//0xFD;
TH1=TL1;
TR1=1;
ES = 1;
}
void UART_send_byte(uint dat) //发送一个字节
{
SBUF=dat;
while(TI==0);
TI=0;
}
void display()
{
UART_send_byte(MLastSelectedSnr[0]);
UART_send_byte(MLastSelectedSnr[1]);
UART_send_byte(MLastSelectedSnr[2]);
UART_send_byte(MLastSelectedSnr[3]);
}
/////////////////////////////////////////////////////////////////////
// 主函数
/////////////////////////////////////////////////////////////////////
void main(void)
{
EA=0; //禁止中断,防止MFRC500未初始化
SCI1_Init();
Mfrc500Init();
EA=1;
while (1)
{
if( M500PiccCommonRequest(0x26,&RevBuffer[2])==MI_OK)
{
M500PiccCommonRequest(0x26,&RevBuffer[2]);
delay_50us(50);
M500PiccCascAnticoll(0,MLastSelectedSnr);
if(M500PiccCascAnticoll(0,MLastSelectedSnr)==MI_OK)
{
display();
}
else
{
M500PiccCascAnticoll(0,MLastSelectedSnr);
}
}
else
{
M500PiccCommonRequest(0x26,&RevBuffer[2]);
}
}
}