I got payed to do that project so I'm afraid I can't just give the code away here.
What have you tried? Post some code, I or someone else might see what you're doing wrong.
As with any project, start small, get the basics going and build on it but try to think ahead.
If you think you're going to do this without reading the datasheet back to front a couple of times - think again.
I used SEROUT2/SERIN2 to communicate with the reader and HSEROUT/HSERIN to communicate with the PC.
You need to poll the CTS signal of the board to know when it's able to receive commands. So these are the very basics:
1) Wait for the CTS signal to high (board busy looking for a card)
2) Wait for the CTS signal to go low (board ready to receive serial data from the PIC)
3) Send the "return card status command" ($53)
4) Receive the card status byte from the reader.
Each bit in the Status byte indicates different things. See the datasheet!
If, for example, bit 2 is set then there's a card "on" the reader and you can then read the Unique Identifier
5) Wait for the CTS signal to high (board busy looking for a card)
6) Wait for the CTS signal to go low (board ready to receive serial data from the PIC)
7) Send the "read UID command" ($55)
8) Recieve 8 bytes depending on card type. First byte is status then comes the UID.
That's the basics. I highly recommend you get the first part going first. Make sure you can poll the reader and output the Status byte to the PC so you can SEE what it's doing - then move on.
/Henrik.
Bookmarks