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);
}
}
RFID click !
Re: RFID click !
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.
Re: RFID click !
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.
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.
Re: RFID click !
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.
Re: RFID click !
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!
Re: RFID click !
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.