Hi,
I started working on a board that include the TRF7960 and a PIC MCU.
I have an old code to read a tag uid that is working well and I try to modify it to read multiple tags.
My reg init:
uint8 RFID_INIT_REG[31] = { 0x21,0x02,0x00,0x00,0xC1,0xBB,0x00,0x0F,0x02,0x21,0x40,0x87,0x00,0x3E,0x00,0x40,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
void rfid_init(){
int i;
TRISDbits.TRISD2 = 0; // RFID EN pin set to output
TRISDbits.TRISD8 = 1; // RFID IRQ pin set to input
TRISBbits.TRISB2 = 0; // RFID SS pin set to output
IFS0bits.SPI1IF = 0; /* Clear IF bit */
//IPC2bits.SPI1IP = (config &0x0007); /* Assign interrupt priority */
IEC0bits.SPI1IE = 1; /* Interrupt Enable bit */
RF_PWR_EN = 1; // enable RFID
spi_init();
for(i=0;i<31;i++)
rfid_setReg(i, RFID_INIT_REG[i]);
RFID_output(TRUE);
}
Then, i try to read multiple tags like so:
void read_TAGID(uint8* tagData){
int i,j,k,slot;
uint8 retMsg[50];
uint8 cmdData[8] ={ 0x8f, 0x91, 0x3d, 0x00, 0x30, 0x06, 0x01, 0x00 };
RF_SS = 0; // clear SS
for(k=0;k<8;k++)
rfid_sendByte(cmdData[k]);
RF_SS = 1; // set SS
uint8 status = rfid_getReg(0x0C);
sprintf(retMsg, "Got from 0x0c: %02X", status);
SendMsg(READ_TAG_ID ,retMsg, strlen(retMsg));
sprintf(retMsg, "Got from 0x1c: %02X", rfid_getReg(0x1C));
SendMsg(READ_TAG_ID ,retMsg, strlen(retMsg));
for (i=0;i<5500;i++) j=1; //delay
rfid_sendByte(0x0F);
rfid_sendByte(0x17);
for(slot=0;slot<16;slot++){
for (i=0;i<5500;i++) j=1; //delay
rfid_getReg(0x1F);
rfid_getReg(0x1F);
for(k=0;k<8;k++)
tagData[k] = rfid_getReg(0x1F);
sprintf(retMsg, "%02X %02X %02X %02X %02X %02X %02X %02X",
tagData[7], tagData[6], tagData[5], tagData[4], tagData[3], tagData[2], tagData[1], tagData[0]);
SendMsg(READ_TAG_ID ,retMsg, strlen(retMsg));
rfid_sendByte(0x0F);
rfid_sendByte(0x16);
rfid_sendByte(0x17);
rfid_sendByte(0x14);
}
I'm searching google endlessly in order to it and I found articles and datasheets but don't understand the mechanism.
Please help me with a code,example or pointers.
Thanks,
Ofer.