RFID click !

General discussion on Libstock website & codes posted on this website.
Post Reply
Author
Message
ishka
Posts: 4
Joined: 26 Jun 2015 11:27

RFID click !

#1 Post by ishka » 26 Jun 2015 14:53

Hi

can anyone please explain me what is the meaning of ((res & 0x08) >> 3) in RFID click example.

void readCmd(){
unsigned short i = 0;

while(1){
CS_rfid = 0;
WriteSPI2(0x03); // 03 poll
res = ReadSPI2;
CS_rfid = 1;

if((res & 0x08) >> 3){ // ???????????
CS_rfid = 0;
WriteSPI2(0x02);
res = ReadSPI2;
dataNum = ReadSPI2;
for(i=0; i<dataNum; i++)
rdata = ReadSPI2;
CS_rfid = 1;
break;
}
CS_rfid = 1;
Delay10TCYx(10);
}
}

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: RFID click !

#2 Post by janni » 27 Jun 2015 13:58

All bits but bit3 in res are masked (zeroed) and then res is shifted three bits to the right thus moving previous bit3 to bit0.

ishka
Posts: 4
Joined: 26 Jun 2015 11:27

Re: RFID click !

#3 Post by ishka » 01 Jul 2015 15:19

Hi,

Thank you for your reply!

one more thing that i didn't understood is that in the example code of RFID there is SPI1_Read(0) and SPI1_Read(1).
what does 0 and 1 in the bracket represents?


Thanking you in advance.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: RFID click !

#4 Post by janni » 01 Jul 2015 17:07

When used to read data, parameter in SPI1_Read is mostly a dummy as there are few SPI devices that can receive while transmitting. And though it's possible to use SPI1_Read instead of SPI1_Write (which is basically the same function, just without returning a result), that's not the case in RFID example code.

ishka
Posts: 4
Joined: 26 Jun 2015 11:27

Re: RFID click !

#5 Post by ishka » 02 Jul 2015 10:15

So it means that whether i pass 0 or 1 as parameter, it doesn't matter? Because i am using MPLABX and in its library spi_read function does not take parameter. But i am not getting any result!

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: RFID click !

#6 Post by janni » 02 Jul 2015 12:13

Sorry to hear that but I don't think it's SPI_Read that is responsible. Anyway, you may verify the communication protocol in datasheet of the chip used in RFID click.

Post Reply

Return to “Libstock Discussion”