05.08.2014 Views

RFID - Elektor

RFID - Elektor

RFID - Elektor

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Programming the MF RC522 Reader IC 9.1<br />

Listing 9.1. Excerpt from RC522RfParameterConfig.cs. (from www.smartcard-magic.<br />

net/smart-card-magic-net/)<br />

▌▌<br />

▌▌<br />

▌▌<br />

▌ ▌<br />

▌▌<br />

▌<br />

▌<br />

▌<br />

▌<br />

▌<br />

▌<br />

▌ ▌<br />

▌<br />

▌<br />

▌ ▌<br />

▌<br />

▌<br />

▌ ▌<br />

▌<br />

▌<br />

▌<br />

▌<br />

▌<br />

▌ ▌<br />

▌ ▌<br />

▌<br />

▌<br />

▌<br />

▌<br />

▌<br />

▌<br />

using System;<br />

using GS.Util.Hex;<br />

using GS.<strong>Elektor</strong>Reader;<br />

using GS.ISO14443_Reader;<br />

namespace GS.<strong>Elektor</strong>RfidReader<br />

▌ {<br />

▌ class RC522RfParameterConfig<br />

▌ {<br />

▌ const byte RxThresholdReg = 0x18; // selects threshold for the bit decoder<br />

▌ const byte DemodReg = 0x19; // defines demodulator settings<br />

▌ const byte ModWidthReg = 0x24; // controls the ModWidth setting<br />

▌ const byte RFCfgReg = 0x26; // configures the receiver gain<br />

▌ public static void Main(MainForm script, string[] args)<br />

▌ {<br />

▌ <strong>Elektor</strong>ISO14443Reader reader = new <strong>Elektor</strong>ISO14443Reader();<br />

▌ try<br />

▌ {<br />

▌ reader.OpenPort();<br />

▌ // RF parameter configuration<br />

▌ reader.RC522.WriteSFR(RxThresholdReg, 0x55); // Bit decoder threshold<br />

▌ // MinLevel, CollLevel<br />

▌ reader.RC522.WriteSFR(DemodReg, 0x4D); // Demodulator Setting<br />

▌ reader.RC522.WriteSFR(ModWidthReg, 0x26); // Modulation width<br />

▌ reader.RC522.WriteSFR(RFCfgReg, 0x59); // Receiver Gain<br />

▌ int ret;<br />

▌ Console.WriteLine(“Wait for new Card...”);<br />

▌ do<br />

▌ {<br />

▌ ret = reader.ActivateCard(RequestCmd.REQA);<br />

▌ }<br />

▌ while((ReaderStatus)ret != ReaderStatus.OK);<br />

copyright <strong>Elektor</strong><br />

Figure 9.2.<br />

Any of the<br />

MF RC522 parameters<br />

can be<br />

changed using a<br />

script.<br />

9.1.2.2 MF RC522 SFR Programming — Card Activation<br />

The programming of the MF RC522 is presented with a card activation example. In this<br />

implementation, the bit frame anti-collision algorithm is omitted for clarity. Should more<br />

387

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!