Dallas' iButton products are a series of new 1-wire bus devices. DS1991 is an encrypted storage information button, encapsulated in a stainless steel shell with a diameter of 16mm. It is small in size, easy to carry and store, dustproof and corrosion-resistant, and can realize password-protected data transmission in harsh application environments. This article introduces the characteristics and working principle of DS1991 and the reading and writing methods of its password-protected storage area.
abstract:
DS1991 is a member of Dallas' 1-wire bus information button family, and is an encrypted memory type information button. It integrates 1Kbit non-volatile memory and encryption protection logic, and is packaged in a stainless steel shell with a diameter of 16mm and a thickness of about 6mm. It is compact, easy to operate, moisture-proof, shock-proof, and dust-proof, and can achieve data transmission with password protection in harsh environments.
1 Features of DS1991
DS1991 is a unique encrypted memory TM card, which provides a reliable protection measure for users' confidential data. DS1991 has a 1152-bit password-protected memory area and a 512-bit non-password-protected memory scratchpad. The password-protected memory is divided into three independently operable key sub-memories (subkey), each of which is 384 bits. Each password sub-area has its own 64-bit password and 64-bit ID code. The read/write operation of the key sub-area requires password verification. The data in the three areas can be operated separately without interfering with each other. The non-password-protected memory area is mainly used for copying encrypted data to ensure the integrity of the data.
2 DS1991 and MCU hardware interface and software design
The hardware interface circuit between DS1991 and MCU is shown in Figure 1.
The interface between DS1991 and microcontroller is very convenient, using only one data line and one address. The data line is controlled by one I/O line of the microcontroller, and the line is connected to a 5kΩ pull-up resistor . DIOBITP1.0; pin definition RETDJNZR6, WRB1
The basis of DS1991 operation is the initialization of 1-wire bus and the timing of reading/writing 1 bit, as shown in Figures 2, 3, 4 and 5. VPULLUP is the potential of point D in Figure 1 when the port line is in input state. Initialization is initiated by the host sending a reset pulse. DS1991 responds with a response pulse to let the host know that DS1991 exists on the bus and is ready for operation. Each byte of command and data is transmitted one by one from the least significant bit. Subroutines RESET, RDBYTE and WRBYTE are subroutines for initialization and reading/writing 1 byte respectively.
RESET:CLR DIO; get the subroutine
MOV R7,#205
DELPP1:NOP
DJNZ R7,DELPP1
SETB DIO
MOV R7,#12
DJNZ R7,$
MOV R7,#27
RESETP1:JNB DIO,RESETP2
DJNZ R7,RESETP1
RESRET:SETB DIO
MOV A,#0EH
RESETP2:MOV R7,#75
DJNZ R7,$
MOV R7,#54
RESETP4:JB DIO,RESETP5
DJNZ R7,RESETP4
RESETP5:MOV R7,#180
DJNZ R7,$
SETB DIO
MOV A,#0
RET
WRBYTE:MOV R6,#8 ; write 1 byte subroutine
WRB1:CLR DIO
MOV R7,#2
DJNZ R7,$
RRC A
MOV DIO,C
MOV R7,#30H
DJNZ R7,$
SETB DIO
NOP
NAP
NOP
RET
RDBYTE:MOV R6,#8 ;Read 1 byte subroutine
RDB1:CLR DUO
NOP
NOP
SETB DIO
MOV R7,#3
DJNZ R7,$
MOV C,DIO
RRC A
MOV R7,#32
DJNZ R7,$
SETB DIO
MOV R7,#3
DJNZ R7,$
DJNZ R6,RDB1
RET
3 DS1991 Laser ROM Code, Memory Structure and Operation
Like all 1-wire bus devices, the host must first perform initialization and ROM operations before it can read and write DS1991 memory operations.
DS1991 has a unique 64-bit laser ROM serial code engraved in the factory. This code will not be repeated with any other 1-wire bus device. The first 8 bits of the code are the 1-wire bus family code, the next 48 bits are the device's unique serial code, and the last 8 bits are the CRC checksum of the first 56 bits of data. The ROM operation instructions establish the connection between the accessed 1-wire device and the host. The ROM operation instructions are shown in Table 1. The memory image of DS1991 is shown in Figure 1.
Table 1 ROM operation instructions
MOV A,#0
RET
WRBYTE:MOV R6,#8; write 1 byte subroutine
WRB1: CLR DIO
MOV R7, #2
DJNZ R7, $
RRC A
MOV DIO,C
MOV R7,#30H
DJNZ R7,$
SETB DIO
NOP
NAP
NOP
RET
RDBYTE:MOV R6,#8 ; read 1 byte subroutine
RDB1:CLR DUO
NOP
NOP
SETB DIO
MOV R7,#3
DJNZ R7,$
MOV C,DIO
RRC A
MOV R7,#32
DJNZ R7,$
SETB DIO
MOV R7,#3
DJNZ R7,$
DJNZ R6,RDB1
RET
3 DS1991 Laser ROM Code, Memory Structure and Operation
Like all 1-wire bus devices, the host must first perform initialization and ROM operations before it can read and write DS1991 memory.
DS1991 has a unique 64-bit laser ROM serial code engraved in the factory. This code will not be repeated with any other 1-wire bus device. The first 8 bits of the code are the 1-wire bus family code, the next 48 bits are the device's unique serial code, and the last 8 bits are the CRC check code for the first 56 bits of data. ROM operation instructions establish the connection between the accessed 1-wire device and the host. ROM operation instructions are shown in Table 1. The memory image of DS1991 is shown in Figure 1.
Table 1 ROM operation instructions
Order | byte | Function |
read ROM | 33H | Read the ROM system code of DS1991 |
Match ROM | 55H | Used to address a specific device when the bus connects multiple devices |
Skip ROM | C H | When there is only one device on the bus, the ROM serial code matching is skipped and the memory is accessed directly. |
Search ROM | F0H | The host uses this command to read the ROM serial code of the device. |
The scratchpad and each subkey area of DS1991 have their own addresses. The scratchpad is 64 bytes in total and is not password protected. It is mainly used to copy data to the key sub-area. 00H to 07H in the key sub-area is the 8-byte ID code of the area, 08H to 0FH is the 8-byte password of the area, and 10H to 3FH is the password-protected data storage area.
The / write operation of the Scratchpad does not require a password, but the correct password must be provided for the copy operation. The password sub-area is protected by a 64-bit password, which greatly improves confidentiality. The operation instructions for the memory are shown in Table 2. The flow of the memory operation instructions is shown in Figure 2.
Table 2 DS1991 memory operation command format
Order | Byte 1 | Byte 2 | Byte 3 | Function | |||||||
bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 | ||||
Write to scratchpad | 96H | 1 1 | Any value between 00H and 3FH | Invert the second byte | Writing data to the scratchpad | ||||||
Read Scratchpad | 69H | Reading data from scratchpa | |||||||||
Copy scratchpad | 3CH | Subke area code 0 0 or 0 1 or 1 0 | 0 | 0 | 0 | 0 | 0 | 0 | Copy the data block from scratchpa to the specified subkey | ||
Read subkey | 66H | Any value between 10H and 3FH | Write data to subkey | ||||||||
Write subkey | 99G | Read data from subkey | |||||||||
Write password | 5AH | 0 | 0 | 0 | 0 | 0 | 0 | Write the password and ID code into subkey |
4 DS1991 memory read and write procedures
The host reads and writes the memory of DS1991, which consists of three steps: initialization, ROM operation and memory reading and writing.
The following program uses the write SUBBYKEY command to write the data of RAM 40H~47H unit into the subkey 0 area 10H~17H, and uses the read SUBBYKEY command to read the content back and store it in RAM 50H~57H. The password and ID code of this area are stored in the table of the program.
; Write the contents of RAM40H~47H units into
;subkey
WRSUBKEY:LCALL RETSET
MOV R2,#99H
MOV R0,#10H
LCALL WRCOM
LCALL IDPASS
MOV R1,#40H
MOV R4,#8
REWRSUB:MOV A,@R1
LCALL WRBYTE
INC R1
DJNZ R4,REWRSUB
LCALL RESET
RET
; Read subkey and store it in RAM 40H~47H
RDSUBKEY:LCALLRESET
MOV R2,#66H
MOVR0,#10H
LCAL WRCOM
LCALL IDPASS
MOVR1,#40H
MOV R4, #8
RERDSUB:LCALLRDYBTE
MOV @R1,A
INC R1
DJNZ R4,RERDSUB
LCALL RESET
RET
IDPASS:MOV R4,#8
MOV R1,#50H
RERD1:LCALL RDBYTE
MOV @R1,A
INC R1
DJNZ R4,RERD1
MOV R4,#8
CLR A
MOV DPTR,#PSTAB
REWR1:MOVC A,@A+DPTR
LCALL WRBYTE
INC A
DJNZ R4,REWR1
RET
IDTAB:DB10H,00H,00H,00H,
DB 00H,00H,00H,00H
PSTAB:DB12H,34H,56H,78H,DB12H,34H,56H,78H
WRCOM:MOV A,#33H
LCALL WRBYTE
MOV R4,#8
RDROM1:LCALL RDBYTE
DJNZ R4,RDROM1
MOV A,R2
LCALL WRBYTE
MOV A,R0
LCALL WRBYTE
MOV A,R0
CPL A
LCALL WRBYTE
RET
Conclusion
The password protected memory area of DS1991 provides users with highly reliable data protection measures. The software and hardware design of the interface between DS1991 and single chip microcomputer provided in this paper has been applied in the information button card type public electric meter system.
Order | byte | Function |
read ROM | 33H | Read the ROM system code of DS1991 |
Match ROM | 55H | Used to address a specific device when the bus connects multiple devices |
Skip ROM | CCH | When there is only one device on the bus, the ROM serial code matching is skipped and the memory is accessed directly. |
Search ROM | F0H | The host uses this command to read the ROM serial code of the device. |
Previous article:Production of online system programmer with serial communication function
Next article:Method of debugging single chip microcomputer hardware using simple tools
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Reflections and how to handle them in high-speed systems
- Share practical tips on eliminating EMI in buck converters!
- The role of capacitors in op amp circuits
- Repairing PCB without drawings, this article is enough
- [Fudan Micro FM33LC046N] PACK package also limits the MDK version?
- Can stm32f407 be used as a USB host to receive serial port data?
- uLisp, a Lisp language for embedded systems
- SensorTile.box firmware upgrade first experience
- EPLAN P8 Advanced Tutorial (Chinese)
- [ESP32-Audio-Kit Audio Development Board Review] Part 3 play_mp3_control