Home
Building an RFID short-range reader using the STM8S
Contents
1. 23 ky Doc ID 17784 Rev 1 3 24 List of figures AN3255 List of figures Figure 1 Short range RFID reader 5 Figure2 Polling flowchart 0 2 0 0 cee RR RII IRR A IM 8 Figure 3 TAG state transition diagram 9 Figure 4 Contactless RFID 5 lt 12 Figure 5 Main application loop 17 Figure 6 2 Page Write flowchart 21 Figure 7 I C post polling buffer read flowchart 22 4 24 Doc ID 17784 Rev 1 ky 255 Application description 1 Application description 1 1 Overview This application is built around a short range RFID reader PCB developed by STMicroelectronics The PCB Gerber files and the user manual CR14 and CRX14 reference design PCB Gerber files UM0672 are available from http www st com This board is designed to be connected to a digital host in this case an STM8S DISCOVERY which manages data transmission and reception through an 2 interface see Figure 1 The tags supported by this application must be based on ST contactless memories compliant with ISO 14443 part2 type B standard for the radio frequency power and signal
2. 14 3 Software description 000 cece eee eee eee eee 15 3 1 STM8S peripherals used by the application 15 3 2 Configuring the STM8S standard firmware library 15 3 3 Application principle 16 Appendix PC memory addressing 19 I C Read and Write 20 1 21 2 2 post polling buffer read flowchart 22 REVISION hISIOFV suck dee E C ee aic d REOR Ra 23 2 24 Doc ID 17784 Rev 1 255 List of tables List of tables Table 1 CR14 control registers 6 Table 2 List of PCB passive components 9 Table 3 List of PCB packaged 10 Table 4 List of tag packaged 10 Table 5 List of other passive 10 Table 6 TAG commands used within this application 16 Table 7 Device Select 19 Table 8 Document revision history
3. 255 YZ Application note Building an RFID short range reader using the STM8S DISCOVERY Application overview High frequency 13 56 MHz RFID solutions offer ideal close proximity identification for product authentication parcel tracking document management library and ticketing applications This application note describes how to build an RFID radio frequency identification short range reader using STMicroelectronics STM8S DISCOVERY and 15014443 type B CR14 contactless coupler The STM8S DISCOVERY and the CR14 communicate through an IC bus The resulting RFID reader can exchange data with ISO 14443 2 type B proximity PICCs proximity integrated coupling cards also called tags Communications are possible only when the tags are present in the electromagnetic field generated by the reader built in antenna Once the STM8S DISCOVERY is powered up through a USB cable connected to the host PC an electromagnetic field is generated by the RFID reader A beep is emitted and the LED LD1 briefly lights up when an ISO 14443 2 type B proximity tag is detected by the reader and its unique identifier UID successfully read The STM8S DISCOVERY can be used to evaluate the main features of all STM8S MCUS even if it is built on an STM8S105C6T6 Reference documents m STM8S DISCOVERY evaluation board user manual UM0817 m Developing and debugging your STM8S DISCOVERY application code UM0834 m User manual CR14 and CRX14 re
4. NumByteToRead 1 Send STOP condition Read one byte from CR14 NumByteToRead 1 ai18404 22 24 Doc ID 17784 Rev 1 ky 255 Revision history Revision history Table 8 Document revision history Date Revision Changes 12 Oct 2010 1 Document migrated from UM0927 rev 1 Doc ID 17784 Rev 1 23 24 255 Please Read Carefully Information in this document is provided solely in connection with ST products STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections modifications or improvements to this document and the products and services described herein at any time without notice All ST products are sold pursuant to ST s terms and conditions of sale Purchasers are solely responsible for the choice selection and use of the ST products and services described herein and ST assumes no liability whatsoever relating to the choice selection or use of the ST products and services described herein No license express or implied by estoppel or otherwise to any intellectual property rights is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or se
5. Send CR14 Device Select Code with R W 1 NO CR14 2 disconnected ACK returned Read data bytes from CR14 ai18403 Reader tag protocol Standard tag commands such as Read and Write are generated by the CR14 using its Input Output Frame register To send a command to the tag the STM8S105C6 host first generates internally the complete frame containing the command code followed by the command parameters if required Only the 2 CRC bytes must not be generated as the CR14 automatically adds them during the RF transmission Once the frame is ready the host writes it into the Input Output Frame register using an 2 Write command If the tag answers the characters received are demodulated decoded and stored into the input output frame buffer During the entire RF transmission the CR14 disconnects itself from the 12 bus On reception of the tag EOF the CR14 checks the CRC and reconnects to the I C bus The host can then get the tag answer frame by issuing an Input Output Frame Register Read command on the IC bus Refer to the CR14 datasheet for details on Read and Write commands Commands and tag states The tag can be switched into different states see Figure 3 The tag only answers specific commands depending on its current state These states are specified by the ISO 15693 standard For details concerning these states refers to one of ST short range contactless EEPROM datasheet for example SRI2K
6. available from http www st com Doc ID 17784 Rev 1 ky 255 Application description 1 3 Figure 3 TAG state transition diagram On field Out of field Initiate or Pcall16 or Slot marker SN Out of field Select Chip ID Selected Completion Deselected Desactivated Selct Chip ID Select Chip ID Read block Write block Get UID ai18400 Hardware requirements The following STM8S DISCOVERY on board resources are used e LEDLD1 Refer Table 2 Table 3 Table 4 and Table 5 for the list of additional hardware required to make this application software run on the STM8S DISCOVERY Table 2 List of PCB passive components Component description Value Comment Resistors R1 N A R2 02 Hardwired addressing of the CR14 bits b3 b2 and b1 of the R3 N A 7 bit C Device Select Code R4 Allow up to 7 CR14 readers to be addressed the same I C R5 N A bus R6 00 R7 00 Doc ID 17784 Rev 1 9 24 Application description AN3255 10 24 Table 2 List of PCB passive components continued Component description Value Comment Serial resistor allowing to fine R8 00 tune the quality factor of the reader antenna Capacitor C1 C2 7 pF crystal oscillator capacitors C3 22 nF C4 22 uF C5 5 pF 50 V C6 100 nF C7 C7 220 pF 50 V 56 pF 50 V Capacitors allowing to
7. interface This application has been tested using a tag based on ST SRI2K short range contactless EEPROM Refer to application note AN2866 explaining how to design a 13 56 MHz tag antenna Figure 1 Short range RFID reader solution Resistors D 9 STLINK STM8S105C6T6 Buzzer STMicroelectronics CR14 STM8S DISCOVERY RFID reader PCB ky Doc ID 17784 Rev 1 5 24 Application description AN3255 1 2 1 2 1 6 24 Short range contactless communication principles CR14 contactless coupler The CR14 is the main component of the RFID reader PCB It interfaces with the following components e Thecontactless tags The data frames exchanged with the tags are compliant with ISO14443 type B radio frequency protocol Data are stored in the CR14 input output Frame registers see Table 1 CR14 control registers e The STM8S105C6T6 through the 2 bus The CR14 is organized as 4 functional blocks e The PC bus controller It handles the serial connection with the STM8S105C6 application host and controls the read write accesses to all CR14 registers It is compliant with the 400 KHz I C bus specification e The RAM buffer The RAM buffer is bidirectional It stores all the request frame bytes to be transmitted to the tag plus all the received bytes sent back by the tag on the answer frame e Thetransmitter It powers the tag by generating a 13 56 MHz signal on an external antenna The result
8. of 4 KHz for sound generation TIM3 The timer is used to measure the LSI frequency with Input Capture 1 to reach with a better accuracy the standard Beeper frequency outputs Configuring the STM8S standard firmware library The stm8s_cont h file of the STM8S standard firmware library is used to configure the library by enabling the peripherals used by the application The following define statements must be present define 1 enables the clock control define GPIO 1 enables the GPIOs define I2C 1 enables the I C interface define AWU 1 enables the Auto wake up define BEEP 1 enables the beeper define TIM3 1 enables timer 3 Doc ID 17784 Rev 1 15 24 Software description AN3255 3 3 16 24 Application principle This application initiates communications with the tags present in the range of the electromagnetic field generated by the reader antenna and read the tag UIDs If the operation succeeds the STM8S105C6T6 emits a beep and blinks LD1 When running the code in debug mode from STVD development tool the UID value can be displayed in the Watch windows The application uses the I C protocol to configure the CR14 embedded on the RFID reader board and to transmit receive frames to from the tags see Table 6 Communications with the tags are managed by the state transition diagram shown in Figure 3 A possible way to improve this application would be to use an LCD screen to disp
9. the tag before this command is issued are ignored Once the peripheral initialization has completed the application code enters a loop in which it checks if a tag is present in the RF field by writing periodically the Initiate command in the CR14 Input Output Frame register see Appendix A I2C memory addressing If no tag is present in the electromagnetic field the STM8S105C6T6 enters the Active halt power saving mode for 512 ms and automatically wakes up to issue a new Initiate command As soon as a tag is present in the electromagnetic field it automatically enters the Ready state in which its 8 bit random Chip ID is initialized When receiving the Initiate command the tag then switches to the nventory state in which its new 8 bit Chip ID random value is set and returned to the CR14 Since this application software does not implement the anti Doc ID 17784 Rev 1 17 24 Software description AN3255 collision mechanism the Chip ID is stored by the host and sent as parameter to the Select Chip ID command issued by the host to the tag The tag then switches directly to the Selected state The Get UID command is then sent to the tag that answers by returning its 8 UID bytes The host emits a beep and lights LD1 for about 1 s 18 24 Doc ID 17784 Rev 1 255 memory addressing Appendix A I C memory addressing To start communicating with the CR14 the bus master initiates a START condition and s
10. 4 registers Its parameters are the buffer containing the bytes to be written to the CR14 the CR14 write address and the number of bytes to be written Figure 6 shows the detailed flowchart of the 12C Page Write function Figure 6 2 Page Write flowchart YES Send START condition NO START condition generated Send CR14 Device Select Code with R W 0 n END of Address transmission NO Send register write address Data byte transfer succeeded NO YES umber of data NO to be written gt 0 v Send Data byte Generate STOP condition Number of data to be written C END 75 Data byte transfer succeeded Doc ID 17784 Rev 1 ai18402 21 24 I C Read and Write functions AN3255 B 2 2 post polling buffer read flowchart This function has been implemented to be used together with the 2 polling function Once an ACK has been returned by I2C CR14 EE AckPolling the I2C CR14 EE PostPolling function reads one by one all the bytes that are available in the Input Output Frame register of the CR14 Figure 7 shows the detailed flowchart of the 2C CR14 EE PostPolling function Figure 7 2 post polling buffer read flowchart CR14 Ack Polling in progress YES NO lt NumByteToRead gt 0 NumByteToRead 1 4 Read one byte Disable the I2C from CR14 Acknoledgement
11. C6T6 microcontroller controls the bidirectional communications with the CR14 through the 2 serial bus refer to the CR14 datasheet Doc ID 17784 Rev 1 11 24 255 Application description Contactless RFID reader schematics Figure 4 Igod ai15858 Cb0 C6L CeL HOM CV0 C6L CeL HIANM AOI ANZ THO T6 L T L HIANM YO 20 61 01 HIANM 9T que IA n ST _ IB Wo aNo 91 18 ms TINY Y L qweqny ER vIXWO A 0S 4d L 93 medano 4 weno e vu a l 0 AUS T I a 7 0 ZHN 9 i 1950 19 5 Tal Ad X tT 4H qND 0 7 PRI JANI A 5 4 JL a 20 PA B s AosadzZ AO0s4d LIO 1 LT 5 82 140 AS AE oT ri Cb0 C6L CVL HIANM 140 ise WIND Ads au 001 A os dcs I 80 3 weqNo 1052A IVNOILdO 8r TENT 1 a Doc ID 17784 Rev 1 12 24 255 Application description The efficiency of data transfers between the RFID reader and tag depends on the tuning of their respective antenna This is done by adjusting the following components Ce isthe serial capacitance used to adapt the impedance of th
12. automated anti collision process from 03h Slot Marker register 1 byte Slot 0 to Slot_15 R Return FFh 04h ST reserved N A must 6 05h ST reserved N A W S CHOSCHOEDR 1 2 2 2 polling using Ack During radio frequency data exchange the CR14 disconnects itself from the IC bus The time needed to complete the exchange is not fixed as it depends on the tag command format To know when the exchange is complete before starting reading the data in the Input Output Frame register the bus master uses an Ack polling sequence that performs the following actions 1 Initial condition a radio frequency data exchange is in progress 2 Step 1 the master issues a START condition followed by the first byte of the new instruction Device Select Code plus R W bit 1 see Appendix A I2C memory adaressing 3 Step2 if the CR14 is busy no Ack is returned and the master goes back to Step 1 If the CR14 has completed the radio frequency data exchange it responds by sending back an ACK thus indicating that it is ready to receive the second part of the next instruction the first byte of this instruction has been sent during Step 1 Figure 2 shows the detailed I C Ack polling flowchart ky Doc ID 17784 Rev 1 7 24 Application description AN3255 1 2 3 1 2 4 8 24 Figure 2 Ack Polling flowchart Radio Frequency data exchange in progress Send START condition
13. e reader antenna RLC equivalent circuit Cs C8 C8 e Cpisthe parallel capacitance used to tune the resonant frequency of the reader RLC equivalent circuit Cp C7 C7 e sis the serial resistor used to fine tune the quality factor of the reader RLC resonant equivalent circuit Rs R8 Refer to application note AN1806 for details on how to design a reader antenna and infer the values of Cp Cg and Rg This document is associated with a software tool using the Grover method to calculate the inductance of rectangular planar antennas Warning values of Cs Cp and Rg are dependant Tuning one of them impacts the 2 others The best compromise must be found to achieve a good tuning for the reader antenna refer to AN1806 Doc ID 17784 Rev 1 13 24 STM8S DISCOVERY configuration AN3255 2 2 1 2 2 14 24 STM8S DISCOVERY configuration Power supply configuration The CR14 of the RFID reader PCB must be supplied from 5 V 500 mV This board being powered from STM8S DISCOVERY Vpp the jumper JP1 of the STM8S DISCOVERY must be set to Vpp 5 V see UM0817 Option byte configuration The STM8S105C6T6 Beeper output is enabled through the alternate function remapping option AFR7 of the OPT2 option byte AFR7 0 port D4 alternate function is TIM2_CH1 default AFR7 1 port D4 alternate function is BEEP required For details on the option byte and alternate function remapping refer to UM0834 and to the STM8S105x
14. ends 8 bits with Most Significant Bit first on the serial data line SDA These bits contain the Device Select Code 7 bits and the RWbar bit According to the IC bus definition the seven Most Significant Bits of the Device Select Code are the Device Type Identifier For the CR14 these bits definition is given in Table 7 Table 7 Device Select code Device Code Chip Enable RWbar b7 b6 b5 b4 b3 b2 b1 bO 1 0 1 0 2 1 RWbar select The 8th bit is the Read Write bit RWbar It is set to 1 for 2 read and to 0 for I C write operations If the data sent by the bus master matches the Device Select Code of the CR14 it returns an acknowledgement on the bus during the 9th bit time The CR14 device generates a NACK if its Device Select Code does not correspond to the data sent It deselects himself from the bus and goes in standby mode Refer to the CR14 datasheet for details regarding the CR14 I C protocol and to the STM8S reference manual for a functional description on IC peripheral Doc ID 17784 Rev 1 19 24 I C Read and Write functions AN3255 Appendix B 2 Read and Write functions This section gives an overview of the main functions controlling the read and write accesses to the CR14 20 24 Doc ID 17784 Rev 1 255 I C Read and Write functions B 1 I2C Page Write flowchart The Page Write function performs write accesses to the CR1
15. ference design PCB Gerber files UM0672 and RFID Gerber files m CR14 datasheet Low cost ISO14443 type B contactless coupler chip with anti collision and CRC management m SRI2K datasheet 13 56 MHz short range contactless memory chip with 2048 bit EEPROM and anti collision functions Application note Antenna and associated components matching circuit calculation of the CRX14 coupler AN1806 m Application note How to design a 13 56 MHz customized antenna AN2866 These documents can be downloaded from http www st com October 2010 Doc ID 17784 Rev 1 1 24 www st com Contents AN3255 Contents 1 Application description 5 1 1 5 1 2 Short range contactless communication principles 6 1 2 1 CR14 contactless coupler 6 1 2 2 IC polling using p ABK 7 1 2 3 Reader tag protocol 8 1 2 4 Commands and tag 8 1 3 Hardware requirements 9 1 4 Application 5 11 2 STM8S DISCOVERY configuration 14 2 1 Power supply configuration 14 2 2 Option byte configuration
16. fine tune the RLC resonant frequency ca ca Sov 22 oy he Diode D1 N4148 Optional Ferrite L3 L4 L5 L6 L7 multilayer SMD ferrites Removal of parasites for tag data reception and IC Table 3 List of PCB packaged components Part name Component name Description Package Contactless coupler Short range RFID compliant with short couplers range 15014443 type B 5016 standard 13 56 MHz crystal Crystal 19 56 Mhiz XTALCMS carrier frequency Table 4 List of tag packaged components Part name Component name Description Package 13 56 MHZ short range Short range contactless SRI2K contactless memory memory used to build a SBN18 chip tag Table 5 List of other passive components Component description Value Comment Resistor Rp4 resistors 4 7 Pull up for I C open drain Doc ID 17784 Rev 1 ky 255 Application description 1 4 Table 5 List of other passive components continued Component description Value Other Comment Piezo buzzer 5 V operating voltage Supports 4 KHz input frequency Application schematics Figure 4 shows the contactless reader implementation schematics The reader is made of two parts e STMicroelectronics RFID reader PCB based on the CR14 short range contactless coupler see Section 1 2 1 e The STM8S DISCOVERY which STM8S105
17. ing field is 10 modulated using ASK amplitude shift keying modulation to transmit data e Thereceiver It demodulates the signal generated on the antenna by the load variation of the tag The resulting signal is decoded by an 847 KHz BPSK binary phase shift keying sub carrier decoder The CR14 generates an electromagnetic field which is rectified to power the tag The reader transmits information to the tag by modulating the carrier wave To transmit information back to the reader the tag backscatters the carrier wave by modifying its own impedance thereby perturbing the field The CR14 chip contains six volatile registers of which three allow to configure the CR14 and to transmit receive frames to from the tag see Table 1 e Parameter register e Input Output Frame register e Slot Marker register For details regarding registers description and CR14 2 protocol refer to the CR14 datasheet Table 1 CR14 control registers Address Description Access Purpose W Set parameter register 00h Parameter register 1 byte R Read parameter register Doc ID 17784 Rev 1 ky 255 Application description Table 1 CR14 control registers continued Address Description Access Purpose Store and send request W frame to the tag Wait for Oth ae Frame 36 bytes tag answer frame R Transfer tag answered frame data to host 02h ST res rved N A ST reserved must not be R used Launch the
18. lay the tag unique identifier UID Another improvement could be to implement the CR14 anti collision capability which allows the reader to select up to 16 tags one at a time during predefined time slots Refer to Figure 5 for the flowchart of the application software main loop Table 6 TAG commands used within this application Tag commands Description Initiate To detect if a tag in Ready state is present in the reader field range Select Chip ID Allow the tag to enter the Selected state Get UID On receiving this command the tag returns its 8 UID bytes Doc ID 17784 Rev 1 ky 255 Software description Figure 5 Main application loop flowchart Make LD1 blink initialization of all peripherals YES Tag detected I2C Write Selected Chip ID STMBS enters Active halt mode for 512 ms New Chip ID I2C Read I2C Write Initiate Read new Chip ID of the tag Read tag Chip ID Tag successfully detected NO tag not selected Make 101 blink Emit a beep I2C Write GetUID UID 12 Read ai18401b During peripheral initialization the application first configures the CR14 parameter register to generate the 13 56 MHz RF field on the reader antenna Prior to issuing a Read Write command such as Get UID to the memory tag the tag state machine must be put in the Selected state by sending a Select Chip ID command All commands sent to
19. names are the property of their respective owners 2010 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Philippines Singapore Spain Sweden Switzerland United Kingdom United States of America www st com 24 24 Doc ID 17784 Rev 1 ky
20. rvices or any intellectual property contained therein UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE ST PRODUCTS ARE NOT RECOMMENDED AUTHORIZED OR WARRANTED FOR USE IN MILITARY AIR CRAFT SPACE LIFE SAVING OR LIFE SUSTAINING APPLICATIONS NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY DEATH OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE ST PRODUCTS WHICH ARE NOT SPECIFIED AS AUTOMOTIVE GRADE MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK Resale of ST products with provisions different from the statements and or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever any liability of ST ST and the ST logo are trademarks or registered trademarks of ST in various countries Information in this document supersedes and replaces all information previously supplied The ST logo is a registered trademark of STMicroelectronics All other
21. x datasheet respectively Doc ID 17784 Rev 1 255 Software description 3 3 1 3 2 Software description STM8S peripherals used by the application The application software uses STM8S standard firmware library to control general purpose functions These peripheral functions are the following Clock CLK The clock control enables and delivers the correct clock frequency to the CPU and peripherals It configures the HSI prescaler division factor to 4 The 2 input clock frequency is 4 MHz to be able to generate correct timings compliant with Fast mode GPIOs They drive the MCU I Os to interface with external hardware They configure PDO port as output push pull high to drive LD1 and switch it off at initialization PD4 port is configured through alternate function remapping to enable the Beeper output pin Pc This peripheral handles the serial connection with the CR14 contactless coupler of the RFID reader board It controls the read write access to the CR14 registers Auto wake up AWU This peripheral is used to provide an internal wake up timebase that is used when the MCU goes into Active halt power saving mode It is configured to wake up the MCU after 512 ms which is a good trade off between the time during which the microcontroller remains in Active halt power saving mode and the time required by the RFID reader to identify the tag Beeper This peripheral drives the Beeper output pin with a signal
Download Pdf Manuals
Related Search
Related Contents
ISB365-1296-01-English Manual 化粧鏡 Intel SR6850HW4 User's Manual La cohésion sociale à travers les Maisons de Quartier Samsung ES80 Uživatelská přiručka Bissell 3-in-1 Owner's Manual Rachel Reupke - Espace Croisé Copyright © All rights reserved.
Failed to retrieve file