NFC/RFID Sensors and Modules

So, hello to all viewers and welcome back to Gettobyte Platform. In This blog you are going to know about RFID Reader MFRC522, which is designed by NXP Semiconductors. Objective would be to interface this module with Host MCU’s like of NXP Semiconductors, STMicroelectronics or other vendors MCU’s. Will make the driver to interface the RFID Reader with any MCU, not unlike just with Arduino and Arduino IDE environment. To make the driver of RFID reader at first, we need to dig into its datasheet, to understand its various sub parts. And that’s all about this blog is gotten going to be, to make the datasheet understand in easy way-out.

MFRC522 Datasheet Explanation

Table of Contents

Next & Previous Blog

RFID Technology

RFID modules is a wireless sensing technology which is used to track/identify/monitor the objects.

 Viewers can refer to this blog to know about RFID technology in detail.

or can watch this video which is in animated format to know about RFID technology.

MFRC522 RFID Reader/PCD

MFRC522 is a highly integrated reader/writer IC for contactless communication at 13.56 MHz. These reader supports the ISO 14443 A protocol for communicating with RFID Tags. They are used to detect the MIFRAME RFID tags.

MFRC522 IC

MFRC522 has internal RF transceiver, which provides a robust and efficient implementation for demodulating and decoding signals from MIFRAME compatible cards using ISO 14443 A protocol. The digital module of MFRC522 manages the complete ISO/IEC 14443 A framing and error detection (parity and CRC) functionality.

MFRC522 supports 3 tags of MIFRAME family, that are MF1xxS20, MF1xxS70 and MF1S50 products.

MFRC522 features

MFRC522 Features

MFRC522 though quite old RFID reader and in today’s time many new advance RFID readers have come up. But so as to get started with this technology as a hobbyist/student/DIY project, it is perfect module to lay your hands on this Technology.

  • MFRC522 has highly integrated analog circuitry to demodulate and decode responses when RFID tags are brought in close proximity of these devices.
  • RFID readers are connected with some host MCU, where the processing of data which is received via RFID tags happens according to the application. MFRC522 can connect with host MCU, using SPI, Serial UART and I2C -bus interface.
  • It supports ISO 14443 A protocol and can be used with MIFRAME family of RFID tags. And in MIFRAME family it supports only MF1xxS20, MF1xxS70 and MF1xxS50 products.
  • It has internal CRC-coprocessor.
  • Internal FIFO buffer which can handle 64 bytes of sending and receiving.
  • It uses the Crypto-1 cipher for authenticating.
  • It supports Internal oscillator for connection to 27.12 MHz quartz crytsal.
  • It is low power device, need 2.5 V to 3.3 V power supply.
  • It also has flexible interrupt modes when some RFID tags are detected and trigering events too. In addition to flexible interrupt, it has programmabe I/O pins and timer.
  • It can perform Internal self-test too.

MFRC522 Functional description

MFRC522 Functional Descriptions

MFRC522 Block Diagram

MFRC522 Block Diagram

Above is the simplified block diagram of MFRC522 module. MFRC522 has an internal memory, power supply, interrupt pins, FIFO buffer, Antenna and analog interface, digital module for communicating with Host MCU. 

Analog Interface handles the modulation and demodulation of the analog signals. FIFO Buffer ensures fast and convenient data transfer.

Register bank are the set of registers through which MFRC522 would be configured and initialized to use. Parameters like Clock, Interrupts, status of errors while communicating with RFID readers, CRC calculation, FIFO configuration and etc need to be configured before using the MFRC522.

How the MFRC522 Internal system works?

Host MCU will send PCD Commands to MFRC522, according to which it will perform some operations. MCU will send these commands by writing into one of the registers of PCD.( For MFRC522 CommandReg is register)

Operations like: 

  • Activation of CRC Coprocessor
  • Transmission of data from FIFO buffer of MFRC522 and activation of receiver circuits to get the response from PICC
  • transfer of data from FIFO to an internal buffer 
  • soft reset and authentication-based operations

Further MFRC522 will emit the commands for communicating with PICC, here referred to as PICC Commands, according to which operation with PICC takes place, like scanning of PICC, selecting the PICC, reading and writing the data on PICC. MFRC522 emits these commands via electromagnetic induction and electric coupling. ( That is the main working principle behind the RFID technology)

Host MCU to PCD

Host MCU will send the commands to PCD, according to which PCD will perform the operations like activation of FIFO buffer or CRC coprocessor, and transmission of data from FIFO. We will name these commands as MFRC522 Commands sets. Host MCU will send those commands to PCD (here MFRC522) by writing into the CommandReg Register using low level Host Interface write API.

  • Idle Command: Places the MFRC522 in Idle mode.
  • Mem Command: Transfers the 25 bytes from the FIFO Buffer to the internal buffer. This command is used when, we want to read the data from PICC( As described in ISO-14443-4 doc), as PICC response is always recorded in PCD FIFO.
  • Generate RandomID: generates a 10-byte random ID number.
  • CalcCRC: Activates the CRC coprocessor or performs a self test.
  • Transmit: transmit data from the FIFO buffer
  • NoCmdChange: no command change, can be used to modify the CommandRef register bits without affecting the command
  • Receive: activates the receiver circuits
  • Transceive: Transmit data from the FIFO buffer to antenna and automatically activates the receiver after transmission.
  • MFAuthent: performs the MIFARE standard authentication as a reader
  • SoftReset: This command performs a reset of the device. The configuration data of the internal buffer remains unchanged. All registers are set to the reset values. This command automatically terminates when finished.

PCD to PICC

Further there are also command set which PCD have to emit to communicate with PICC and enter the PICC into some state machine.

PICC States:

  1. Power-off State: In the POWER-OFF state, the PICC is not powered by a PCD operating field
  2. Idle State: In the IDLE state, the PICC is powered. It listens for commands and shall recognize REQA and WUPA commands. 
  3. Ready State: Cascade levels are handled inside this state to get the complete UID. PICC enters the ACTIVE state when it is selected with its complete UID.
  4. Active State: PICC complies with ISO-14443-4 to accept protocol activation commands (RATS)
  5. HALT State: In this state PICC only responds to WUPA command.
  6. Protocol State: PICC behaves according to 1s014443-4 specifications.

We will name these commands as PICC commands. Host MCU will write these PICC command into the PCD FIFO (refer the MFRC522 FIFO section on how to write the data on FIFO). PCD would transmit the FIFO data when it enters the Transceiver state machine (refer above topic).

PCD would transmit these commands via the electromagnetic induction and communicates with PICC via electronic coupling. PCD’s have RF transceivers through which it emits the electromagnetic waves with commands sets encoded in them. PICC have antenna and small circuitry, which gets energized via electromagnetic waves emitted by PCD and then further both PCD and PICC get coupled together to have 2 way wireless communication. How PCD would send commands to PICC and in return how PICC would respond, that is done according to IS014443 protocol. ISO14443 specifies all the frame formats,PICC command  and their format ,  modulation schemes for RFID technology. 

PICC Frame formats:

  1. Short Frame:
  2. Standard Frames

PICC Command Set:

  1. REQA/WUPA Command: This command is send by PCD to scan the valid and IS014443 compatible PICC’s.  This command is in short frame format. Host MCU will write this command into the PCD FIFO, from where this command is transmitted and emitted wirelessly. Response to this command is with ATQA. PICC are in Idle state when listening to this command and after successfully transmitting the ATQA response they enter into Ready State. These commands consist of 7 bits, as specified below:
  2. ANTICOLLISION/SELECT Command: PICC are in ready state when listening to this command and after this command they enter into ACTIVE STATE. This Command is used to get the UID of the scanned PICC and further select the corresponding PICC for Reading and writing data from it. For the MF1S503 PICC’s UID is of 4 bytes, for that only 1 cascade level is needed.

These commands need to be configured and then these bytes are written into The PCD FIFO for transmission and emission of signal to PICC wirelessly. This Command consists of:

  • Select code SEL(1byte): Specify the cascade level. 
  • No of valid bits NVB (1 byte): specify number of bytes that would be transmitted by PCD to PICC (including SEL, NVB and below point)
  • 0 to 40 data bits of UID according to value of NVB.

ANTICOLLISION Command consist of:

  1. Select Code: Cascade level 1= 0x93
  2. No of valid bits NVB = 0x20

Response to ANTICOLLISION Command is with the UID of the Scanned PICC(0xEA, 0x24, 0x77, 0x15) and its CRC(0xAC).

  1. SELECT Command consists of:
  • Select code: Cascade level 1 = 0x93
  • No of valid bits NVB – 0x70
  • 0 to 40 data bits of UID that has been received in ANTICOLLISION Command( 0xEA, 0x24, 0x77, 0x15)
  • CRCA(1 byte) : CRC of SELECT Command would be calculated by PCD and then it would be sent to PICC. And When PICC receives the SELECT Command it will check this CRCA and then will send the ACK.(0xAC)

Response to SELECT Command is with the Select Acknowledge:

MFRC522 Hardware and Pinout

MFRC522 IC has 32 pins in total and it comes in SOT617-1 package.

MFRC522 Pinout

Pin description can be found from the datasheet of MFRC522. To use the MFRC522 IC its module is widely available and quite inexpensive. Can be brought from Robu at cost of 150 rupees. With the module an RFID tag and a key fob tag of MIFRAME Classic 1KB comes in.

MFRC522 Module

In MFRC522 module, IC has 8 pins exposed out for connection and connecting to host MCU.

  • The module has 4 pins exposed out for connecting it to host MCU using either SPI, I2C or UART. By default, reader can communicate with a microcontroller over a 4-pin SPI with a maximum data rate of 10 Mbps. It also supports I2C and UART protocols. As told in MFRC522 functional description part, MFRC522 checks the host interface type automatically depending on the signals on it’s control pins.
  • MFRC522 module has 1 interrupt pin also exposed out, which can be used to trigger interrupts to alert the microcontroller when a RFID tag is in the vicinity.
  • And remaining 3 pins are power supply pins and a reset pin. Reset pin is used for power down mode and reset signal. Module requires the power supply of 3.3 V, that is provided via VCC and GND pins.

Other vendor RFID readers

STMicroelectronics

Texas Instruments

Infenion technologies

Sensor & Modules to explore

Technologies to Explore

Other Blog to Explore

About ARM Processor’s

first View What is a Processor Processor is programmable electronic circuitry that performs operations according to the instructions stored in memory. The processor as of itself does not have the memory and I/O devices. The processor reads the instructions stored in the memory, interprets it, and stores the output in memory or signals the I/Os. Processor Consists of the Processor core which contains circuitry for instruction fetching, decoding, and execution, register banks, and control units. According to the architecture design of the processor, the different processors have different components. For example, ARM cortex-M4 processors have NVIC, MPU, Floating point units, optional debug subsystems. This allows the microcontroller vendors to design differently. A block diagram of the microcontroller. Fig 1.2 – A microcontroller contains Many different blocks How does Processor control the world? Processors become an integral part of our life. We come across many devices which have processors embedded in them. For example: The smartphone on which I am writing this article has ARM cortex-A55 and cortex-A75 as processor,   The Famous Tesla motors FSD Self-driving computer has many ARM processors. To give the idea of how processors are running the world look at these two examples. Upto 2019, Arm partners have shipped more than 160 billion Arm-based chips. Due to the shortage of semiconductor chips(processors) many car manufacturing companies had to reduce the number of cars manufactured. ARM Processor ARM Processor ARM processors are designed by ARM Ltd., ARM does not manufacture processors or sell the chips directly. Instead ARM licenses these designs to other semiconductor companies so that they can make their processor, microcontroller, SOCs as ARM processors are configurable. In the Cortex processor range, the processors are divided into three profiles: 1) The A Profile is designed to handle complex applications such as high-end embedded OSs. 2) The R profile processors are targeted primarily at the high end of the real-time market. These are applications, such as hard drive controllers, automotive systems, etc. 3) The M profile processors target smaller-scale applications such as microcontrollers and mixed-signal design. ARM CortexA1) The A Profile is designed to handle complex applications such as high-end embedded OSs.Click HereARM Cortex RThe R profile processors are targeted primarily at the high end of the real-time market. These are applications, such as hard drive controllers, automotive systems, etc.Click HereARM Cortex MThe M profile processors target smaller-scale applications such as microcontrollers and mixed-signal design.Click Here Previous Next ARM develops new processors, new instructions, and architectural features are added from time to time, as a result, there are different versions of the architecture. For example: ARM7TDMI is based on the architecture version ARMv4T. ARMv5TE architecture was introduced with the ARM9E processor families. With the ARM11 Processor family, the architecture was extended to ARMv6 with memory system features and SIMD instructions included.  Cortex family processors are based on ARMv7 and ARMv6. The cortex-M3 and cortex-M4 processors are based on ARMv7-M architecture. The architecture evolution of the ARM can be seen in the following (Fig 1.4). All the cortex-M processors support Thumb-2 technology(16-bit and 32-bit instructions), with no need to switch the processor between Thumb state and ARM state. Keil MDK-ARMIAR systems(Embedded workbench for ARM Cortex-M) GCC_based IDEs Previous Next For Programming and debugging ARM Processor based MCU’s, we will be using Microcontrollers of different vendors like: STMicroelectronics and NXP Semiconductors. We will be using STM32 Family of STMicroelectronics and S32 Family of NXP Semiconductors. Both of these are based on ARM Processor and have rich set of features and specifications which are ideal for learning embedded systems. Now both the companies provide their own IDE’s for  : STM32CubeIDE and S32 Design IDE for respective family of MCU mentioned above. Or we can also use the Above-mentioned IDE’s which are general IDE’s can be used to program any ARM processor based MCU. But recomended one is to use Vendor specific IDE as it has many extra featutes for programming. CMSIS The Common Microcontroller Software Interface Standard(CMSIS) was developed by ARM to allow microcontroller and software vendors to use a consistent software infrastructure to develop software solutions for cortex microcontrollers. THE AIM OF CMSIS: Software reusability: make it easier to reuse code with different Cortex-M processors, reducing time to market and verification efforts.  Software compatibility: Due to consistent software infrastructure, software from various sources can work together, reducing the risk in integration.  The CMSIS allows easy access to processor core features from the c language.  CMSIS-compliant device drivers can be used with various compilation tools. CMSIS started out as a way to establish consistency in device-driver for the Cortex-M microcontrollers, and this has become CMSIS-Core. Since then, additional CMSIS projects have started: CMSIS-Core  A set of APIs for applications developers to access the features on the Cortex-M processor regardless of microcontroller devices and toolchain used. CMSIS-DSP library This library is intended to allow software developers to create DSP applications on Cortex-M microcontrollers easily. CMSIS-SVD the System View Description in an XMl-based file format to describe peripheral set in microcontroller products. CMSIS-RTOS  the CMSIS-RTOS is an API specification for embedded OS running on Cortex-M Microcontrollers. CMSIS-DAP the CMSIS-DAP(Debug Access Port) is a reference design for a debug interface adaptor, which supports USB to JTAG/Serial protocol conversions. The CMSIS files are integrated into device-driver library packages from the microcontroller vendor. So when you are using CMSIS-compliant device-driver libraries provided by the microcontroller vendors, you are already using CMSIS. We can define the CMSIS into multiple layers: Core peripheral Peripheral Layer Name definitions,address definitions, and helper functions to access core registers and core peripherals. This is processor specific and is provided by ARM. Device Peripheral Access LAyer:  Name definitions, address definitions of peripheral registers etc. This is device specific. Access Functions For Peripherals Access Functions For Peripherals How do I use CMSIS-Core ? Add Source files to the project. This includes: Device specific, toolchain-specific startup code, in the form of assembly or C. Device-specific device initialization code(e.g. System_c). Add header files into the search path of the project: A device-specific header

Read More »
Embedded Basics
Kunal Gupta

Memory System in Microcontrollers

Table of Contents Memory Controller (MCU)  It is a digital circuit that manages the flow of data going to and from the computer main memory. MCU can be a separate chip or integrated into another chip such as being placed on the same die of a microprocessor. In the latter case it is known as an integrated memory controller. Memory controller is also called a Memory Chip Controller(MCC) or Memory Control Unit.(MCU). Now Main memory can be directly or indirectly connected to the CPU via memory bus. Is the only memory that is directly accessible to CPU The CPU continuously reads instructions stored in Main Memory and executes them as required. Types of Main Memory/Primary Storage are: RAM(Random Access Memory) Processor Registers Processor Cache Processor Registers: are located inside the processors and are the fastest accessible memory by CPU of computers data storage. Processor Cache / cache memory: is intermediate stage b/w Processor registers and RAM. Most actively used information in the RAM is stored in the cache memory. Random Access Memory(RAM): is a main memory which is directly accessible by CPU (though it is slowest of the above mentioned Primary Storage). RAM(Random Access Memory) It is volatile memory that loses content on power off. It is the main memory with the largest size and it stores the working data and machine code.  (Machine Code – is instruction that can be executed directly by CPU. Each instruction tells the CPU to perform a task like load, store, jump or ALU operation on the data of Processor Register or Processor Core) So RAM stores the instructions and the data on which instruction has to be done. When the computer is turned on, it loads data to RAM. Programs that are currently running are stored in RAM. Now, there are 2 main types RAM: SRAM  2) DRAM  As the RAM types used for Primary storage are volatile, a computer containing only such storage would not have a source memory to read instructions from, in order to start the computer. Hence the non – volatile primary storage containing a small start-up program(BIOS) is used to bootstrap the computer.The non-volatile technology used for this purpose is ROM(Read Only Memory). ROM( Read Only Memory) It stores the program that is rarely changed during the life of the system and it contains the data for initialising the system and also user application program. → When Powered on CPU has no software in its main memory (as main memory mainly RAM:  that tells the instructions to CPU, is volatile in nature) → ROM stores the initial program that runs when the computer is powered on. → The computer first executes a relatively small program stored in ROM(Read Only Memory) along with a small amount of data, to access the non-volatile devices. In short ROM contains the program that allows a computer to startup each time it is turned on. ROM also performs large Input/Output tasks and perform programs or software instructions. Author: Kunal Gupta

Read More »

Build Technology in Microcontrollers

Why building the project is required ? so After, we have developed/configured the code and we have got the .c & .h files in our project. Now microcontrollers can’t understand the text which is written in these files. They only understand the Binary language of 0 & 1. So we have to convert these .c & .h files into a single file of binary language which the microcontroller can understand. Now these .c and .h files can be in 1000 numbers in some projects. So you can think of how much processing is done to analyze all files, check them for any errors and then convert them into a single file of binary language. This work is done by compilers and the build process. This technology is truly amazing, and its process is even more interesting. What is building the project in embedded and how is it done? In embedded “building the project” refers to the process of compiling and linking the source code and resources of an embedded software application to create an executable binary file that can be loaded onto the target embedded hardware platform. In Embedded, Build process is the process of converting multiple source files into a single file that can run on a computer. So as to understand this process and the technology behind it, let’s understand the procedure/step involved in doing so. Preprocessing(.i files) Compilation(.s files) Assembly(.o files) Linking(.elf files) Preprocessing(.i files) Preprocessing :-  Before the actual compilation, the C preprocessor comes into play. It handles directives that start with `#`, such as `#include` and `#define`. It performs macro expansion and file inclusion. The preprocessor generates a modified version of your code, often saved with a `.i` extension. Compilation(.s files) In this phase, the preprocessed code (`.i` files) is translated into assembly code. This step is performed by the C compiler (e.g., `gcc` for GNU C Compiler). The compiler checks your code for syntax errors and generates an assembly code file (usually with a `.s` extension). Assembly(.o files) The  code generated by the compiler is not yet in a machine-executable format. It’s a human-readable representation of the code. The assembler takes this assembly code and translates it into machine code, generating an object file (typically with a `.o` or `.obj` extension). Linking(.elf files) Most C programs consist of multiple source files, and each one might produce an object file. The linker (e.g., `ld` for GNU Linker) combines these object files along with any necessary system libraries to create an executable binary file. This is the final output of the compilation process, often with no file extension or a `.exe` (on Windows) or no extension (on Unix-based systems) for executable files. It’s important to note that the compilation process can be controlled through various compiler options, allowing you to customize how your code is compiled, optimize it, and handle various aspects of the process. Building an embedded project is a crucial step in the development process, as it ensures that the software is correctly translated into machine code and can run effectively on the embedded hardware, meeting the project’s functional and performance requirements. After the building process is done then which file is created. After the build process is done then these files are created and then deployed onto the target embedded hardware. Executable Binary (Firmware) : This is the primary output of the build process. It’s a binary file that contains the machine code instructions and data necessary for the embedded system to execute your program. The format of this binary file may depend on the microcontroller or processor used and can include extensions like .bin, .hex, .elf, .s19, etc. Object Files : During compilation, each source file is typically compiled into an object file (with extensions like .o or .obj). These object files contain machine code generated from the corresponding source code and may include debugging information. Debug Information : Debugging information (often in a format like DWARF) can be included in the binary or stored in separate files. This information helps debuggers associate machine code instructions with your original source code, making it easier to debug your program. Hexadecimal Files : In some cases, especially when programming microcontrollers, you might generate hexadecimal files (with extensions like .hex) that specify the memory contents, including both code and data, in a human-readable format. Assembly Listings : Some build systems can generate assembly listings (with extensions like .lst) that show the generated assembly code alongside your source code. This can be useful for understanding how your high-level code translates into machine code. 7. Other Output Files : Depending on your specific development environment and tools, you might encounter other files related to the build process, such as project configuration files, build logs, or build artifacts generated by plugins or extensions. Like the Cmake , SDK files etc. In this IDE when the build process is done the compiler gives us a .elf file that can be loaded onto the target embedded hardware. The exact set of files generated can vary widely based on your development workflow and tools, so it’s important to consult the documentation for your chosen development environment and build system to understand the specifics for your project.( To understand build process and specifies of S32K144 MCU, refer this).   Which tools are used in building the project? When we build an embedded project there are some files and a compiler that is used to build the project.  Makefile Linker script Startup code GNU GCC Compiler Make file :-   A makefile can be considered as a script or a set of commands which help build, compile, link the entire project in order to create an executable. The makefile defines a set of tasks to be executed.A makefile does not have any extension. The makefile has to be specifically named as “makefile”. Linker Script :- A linker script is used to specify how object files should be linked together to create the final executable binary. It defines the memory layout of the

Read More »

Bluetooth Low Energy (BLE)

Motivation is necessary to reach to our goals but discipline is needed to make them achievable. What is Bluetooth Low Energy? This series of blogs on BLE, is for anyone who is going to start with Bluetooth Low Energy. Bluetooth energy comes under the short range wireless communication protocols of IoT. So lets start by understanding what is BLE. Bluetooth is a wireless communication protocol that is started as a cable replacement technology to replace wires in devices like mouse, keyboards and etc. It operates at 2.4Ghz in unlicensed ISM frequency brand. Their are two types of Bluetooth devices: one is Bluetooth Classic(BR/EDR) and Bluetooth Low Energy. Bluetooth versions from Version 1.0 to 3.0 are referred as Bluetooth Classic and from 4.0 to latest version 5.2 are referred as Bluetooth Low Energy(BLE). Bluetooth protocol is backwards compatible. Bluetooth Classic technology is developed as a wireless standard allowing cables to be replaced connecting portable and fixed electronic devices, but it cannot achieve extreme level of battery life because of its fast hopping, connection oriented behaviours and relatively complex connection. Bluetooth Classic further has Basic Rate mode(V1), Enhanced Data Rate mode(V2) and High Speed mode(v3). In this article we will not dwell much into the Bluetooth Classic, our discussion area will be confined to Bluetooth low Energy. BLE stands for Bluetooth Low Energy, which has been created for the purpose of transmitting very small packets of data at a time, while consuming significantly less power then Bluetooth Classic. Now for working with any wireless communication protocol, their are 2 important concepts that have to be understood for it. Its Communication Protocol Architecture and Communication protocol Stack( it is the firmware implementation of the Architecture). So for proceeding with BLE, we will first understand Its architecture, about the terms like GATT,GAP, HCI and how does Bluetooth low energy works and then further will understand its stack on Nordiac devices. Click here Read more such articles: Author: Kunal Gupta

Read More »
Kunal Gupta
Author: Kunal Gupta

Author

Kunal Gupta

Leave a comment

Stay Updated With Us

Error: Contact form not found.

      Blog