Data Sheet

Copyright © Parallax Inc. RFID Read/Write Module, Serial (#28440) v1.0 6/29/2010 Page 10 of 10
' Status/error return codes
ERR_OK CON $01 ' No errors
ERR_LIW CON $02 ' Did not find a listen window
ERR_NAK CON $03 ' Received a NAK, could be invalid command
ERR_NAK_OLDPW CON $04 ' Received a NAK sending old password (RFID_SetPass),
' could be incorrect password
ERR_NAK_NEWPW CON $05 ' Received a NAK sending new password (RFID_SetPass)
ERR_LIW_NEWPW CON $06 ' Did not find a listen window after sending
' old password (RFID_SetPass)
ERR_PARITY CON $07 ' Parity error when reading data
' -----[ Variables ]------------------------------------------------------------------
buf VAR Byte(12) ' data buffer
idx VAR Byte ' index
idy VAR Byte
' -----[ EEPROM Data ]----------------------------------------------------------------
' -----[ Initialization ]-------------------------------------------------------------
Initialize:
PAUSE 250 ' let DEBUG open
DEBUG CLS ' clear the screen
DEBUG "Parallax RFID Read/Write Module Test Application", CR,
"------------------------------------------------", CR, CR
' -----[ Program Code ]---------------------------------------------------------------
Main:
DEBUG "Reading tag's unique serial number..."
Read_Tag:
SEROUT RFID_TX, Baud, ["!RW", RFID_Read, ADDR_Serial] ' Read tag's serial number
SERIN RFID_RX, Baud, [STR buf\5] ' Get status byte and data bytes
IF buf(0) <> ERR_OK THEN Read_Tag ' If we get an error, keep trying
' until the read is successful
FOR idx = 1 TO 4 ' Print data
DEBUG HEX2 buf(idx)
NEXT
DEBUG CR
DEBUG "Writing and verifying data to tag..."
Write_Tag:
SEROUT RFID_TX, Baud, ["!RW", RFID_Write, 3, $FE, $ED, $BE, $EF] ' Write $FEEDBEEF
' into address 4 (user EEPROM area)
SERIN RFID_RX, Baud, [buf(0)] ' Wait for status byte
IF buf(0) <> ERR_OK THEN Write_Tag ' If we get an error, keep trying
' until the write is successful
DEBUG "Success!", CR
DEBUG "End of test.", CR
END
' -----[ End of File ]----------------------------------------------------