This article covers how to extract and display the twelve byte unique tag ID received by RFID module on LCD using interrupt method. Before proceeding to this article readers must have knowledge of serial interrupt and LCD. In the previous article of RFID, polling method was used where the microcontroller was continuously monitoring the RXC flag. Keeping the microcontroller busy in monitoring the flag is not a good programming technique, so instead of polling method a programmer should prefer using interrupts.
Since the output data of the RFID
module uses RS232 protocol and is serial in nature, serial interrupt is used to receive the twelve byte unique ID. Whenever an RFID tag comes in the proximity of the RFID reader module, the module transmits the twelve byte unique ID. Every time one byte of data is received, the controller is interrupted and the corresponding ISR gets executed, which stores the byte in a temporary variable and sends it to the LCD for display.
Since the length of the tag is twelve characters (and hence the serial interrupt will be generated twelve times one after the other) it must be noted that while defining ISR it should not be too long or consume more time. If ISR executes for a longer time then it may skip some data in case another interrupt is generated. In simple words the first ISR would not have executed completely and second ISR will be generated. This would cause data loss.
The following is an ISR for the serial interrupt. When an interrupt is received, the variable get incremented and if the value of i is greater the 13, the incoming serial value will start writing from 0th position of second line. Since the unique id of the tag coming from RFID module is of twelve byte so, when the value of variable ‘i’ reaches 12 (i= 12) it means that one set of data is complete and the next coming value of data must be from next card.
value = UDR; // Put the received byte value into the variable “value”
LCD_write(value); // write receive data to LCD
Low cost PCB on PCBWay - only $5 for 10 PCBs and FREE first order for new members
PCB Assembly service starts from $88 with Free shipping all around world + Free stencil
PCBWay 2nd PCB Design Contest