我想问一下RC522 这块RF 芯片能不能实现有卡来了产生一个中断,然后通知 MCU?我看到的例程基本上是采用查询的方式,不停地查找,我想用中断的方式操作,再则我配置了中断寄存器,不知道咋的就是外部中断引脚没有信号呀,一直是低电平,谁能给我个指导,高了好了没出来,下面是 RC522的寄存器配置。
char M500PcdConfigISOType(unsigned char type)
{
char status;
if (type == 'A') //ISO14443_A
{
ClearBitMask(Status2Reg,0x08);
//WriteRawRC(CommandReg,0x20); //as default 0x20
WriteRawRC(ComIEnReg,0x7f);
//as default 0x80
status = ReadRawRC(ComIEnReg);
WriteRawRC(DivIEnReg,0x80);
//as default 0x00
status = ReadRawRC(DivIEnReg);
WriteRawRC(ComIrqReg,0x7f);
//as default 0x04
status = ReadRawRC(ComIrqReg);
//WriteRawRC(DivIrqReg,0x0); //as default 0x00
WriteRawRC(Status2Reg,0x0);
//80 //trun off temperature sensor
status = ReadRawRC(Status2Reg);
WriteRawRC(WaterLevelReg,0x08);
//as default 0x08
status = ReadRawRC(WaterLevelReg);
WriteRawRC(ControlReg,0x10);
//as default 0x10 timer on/off
status = ReadRawRC(ControlReg);
//WriteRawRC(CollReg,0x80);
//as default
WriteRawRC(ModeReg,0x3D);
//3F ---TxWaitRF bit
status = ReadRawRC(ModeReg);
WriteRawRC(RxSelReg,0x86);//84
// WriteRawRC(RxThresholdReg,0x84);//as default
// WriteRawRC(DemodReg,0x4D); //as default
// WriteRawRC(ModWidthReg,0x13);//26
WriteRawRC(RFCfgReg,0x7F); //4F
/* WriteRawRC(GsNReg,0x88); //as default???
WriteRawRC(CWGsCfgReg,0x20); //as default???
WriteRawRC(ModGsCfgReg,0x20); //as default???
*/
WriteRawRC(TReloadRegL,30);//tmoLength);// TReloadVal = 'h6a =tmoLength(dec)
WriteRawRC(TReloadRegH,0);
WriteRawRC(TModeReg,0x8D);
WriteRawRC(TPrescalerReg,0x3E);
// PcdSetTmo(106);
delay_10ms(1);
 
cdAntennaOn();
}
else
{
//return -1;
return 2;
}
return MI_OK;
}
一周热门 更多>