Application of X25165 chip in 8051 system

Publisher:SparkleMagicLatest update time:2012-03-01 Source: 国外电子元器件 Keywords:MCU  Watchdog  X25165 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The Z25165 chip produced by Xicor Corporation of the United States is an integrated circuit product that integrates the functions of watchdog, voltage monitoring and serial EEPROM. The application of this chip will help simplify the structure of the single-chip computer system, reduce the cost of the system, reduce the space requirement for the circuit board, and increase the reliability of the system.

1 Chip Introduction

The pin arrangement of X25165 is shown in Figure 1, and the function description of each pin is listed in Table 1.

X25165 uses a simple three-wire bus serial peripheral interface (SPI). All operation codes, byte addresses and written data for chip operations are input from the SI pin. The written data is latched on the rising edge of the serial clock (SCK). The data read from the chip is serially shifted out from the SO pin and output on the falling edge of the serial clock.

The chip's watchdog timer and Vcc voltage monitor both provide independent protection for the microprocessor. When a system failure occurs, as long as the watchdog timer reaches its programmable timeout limit, the RESET pin immediately and automatically generates a high-level reset signal that lasts 200ms. When the power supply voltage Vcc drops below 4.5V, the RESET pin immediately and automatically generates a main-level reset signal and protects until the power supply voltage returns to normal. When the system power is powered on or off, the RESET pin also immediately and automatically generates a high-level reset signal. In this way, the occurrence of system crashes, data miswriting, and misoperation can be effectively prevented.

Table 1 Application of X25165 chip in 8051 system

Pin Name

illustrate

CS Chip select input (active low)
SO Serial Output
SI Serial Input
SCK Serial clock input
WP EEPROM write protection input
RESET Reset signal output
Vss land
Vcc Supply voltage

The X25165 chip has a 2k×8-bit serial EEPROM inside, each byte can be erased and written more than 100,000 times, and the internal data can be saved for more than 100 years. When used, the specified block can be locked by programming to prevent the saved data from being destroyed due to misoperation and other reasons.

2 Working Principle

2.1 Instructions

X25165 has seven instructions (see Table 2). All operations on the chip need to be completed by writing commands to the instruction register. All instructions, addresses, and data are transmitted serially in the form of high-order bits first (MSB).

Table 2 Instruction set

Command name Instruction Format operate
WREN 0000 0110 Set the write enable latch (allow write operations)
SFLB 0000 0000 Set the FLB bit
VRDI/RFLB 0000 0100 Reset write enable latch/reset FLB bit
RDSR 0000 0101 Read Status Register
WRSR 0000 0001 Write Status Register
READ 0000 0011 Read data from the specified starting address
WRITE 0000 0010 Write data to the specified storage unit

2.2 Status Register

X25165 has an eight-bit status register. The contents of the status register can be read at any time through the RDSR instruction, and certain bits in the status register can be set through the WREN, SFLB, WRSR and other instructions. The format of the status register is as follows:

7 6 5 4 3 2 1 0
WPEN FLB WD1 WD0 BL1 BL0 WEL WIP

WIP: is a read-only bit used to indicate whether the chip is busy with an internal non-volatile write operation.

WEL: Write enable, indicating the current state of the write enable latch; [page]

BL1, BL0: Set the block protection address range of EEPROM, see Table 3;

Table 3 Block protection address range

BL1 BL0 Protected address range
0 0 none
0 1 $0600……$07FF
1 0 $0400……$07FF
1 1 $0000……$07FF

WD0, WD1: Select the watchdog timeout period, see Table 4;

Table 4 Watchdog timer timeout period

WD1 WD0 Watchdog timeout period
0 0 1.4 seconds
0 1 600 ms
1 0 200 ms
1 1 prohibit

FLB: read-only bit, indicating the status of a volatile bit, which can be set and cleared by SFLB and RFLB instructions. This bit is automatically cleared when power is turned on.

WPEN: This is a non-volatile bit that can be programmed using the WRSR instruction. This bit and the WP pin can be used together to programmatically implement hardware write protection (see Table 5). When the WP pin is low and the WPEN bit is set, write operations to all status registers are prohibited.

Table 5 Block Protection Matrix

Status Register Status Register Chip Pins EEPROM EEPROM Status Register
WEL WPEN WP Protected Block Unprotected Blocks WPEN, BL0, BL1, WD0.WD1, BITS
0 × × Protect Protect Protect
1 1 0 Protect Writable Protect
1 0 × Protect Writable Writable
1 × 1 Protect Writable Writable

3 Chip Application

3.1 Hardware interface circuit

In an 8051 single-chip microcomputer system, the chip can be used according to the connection method shown in Figure 2.

3.2 Software Interface Design

According to the connection method in Figure 2, the author has written seven practical application interface programs for your reference.

a. Serial output of the program

The data in accumulator A is serially output to the X25165 chip in the order of the most significant bit first (MSB).

WD-OUTB: MOV R7, #08H; 8 bits of data to be transferred

WD-OUTB1: CLR P1.2; make SCK low

RLC A; shift the output bit into C

MOV P1.1, C; carry bit is shifted into SI

SEIB P1.2; make SCK bit high

DJNZ R7, WD-OUTB1; Determine whether the loop is finished

CLR P1.1; Clear SI

RET

b. Serial input subroutine

Read 1 byte of data serially from X25165 into accumulator A in the order of high bit first (MSB).

WD-INB: MOV R7, #08H; 8 bits of data to be received

WD-INB1: SETB P1.2; generate SCK pulse

CLR P1.2 ;

MOV C, P1.0; S0 moves into carry position C

RLC A; accumulator A with carry bit shifted

DJNZ R7, WD-INB1; Determine whether the loop is finished

RET

c. Read status register subroutine

Used to read the status register contents from X25165, and the read contents are stored in A.

WD-RD-SR: CLR P1.2; make SCK low

CLR P1.3; Chip select CS valid

MOV A, #05H; RDSR instruction sends accumulator A

LCALL WD-OUTB ; Output RDSR instruction

LCALL WD-INB ;Read the status register contents

CLR P1.2; Make SCK low

SETB P1.3; Chip select CS is invalid

RET

d. Write status register subroutine

This subroutine can set the block protection address range and the programmable watchdog timer timeout period. In the subroutine, the chip select signal must be enabled first, and then the write enable latch must be set using the WREN instruction. After the 8-bit instruction is output, the chip select signal must be pulled high to make the command effective. Similarly, the chip select signal must be pulled high after the data output is completed. [page]

WD-WR-SR: CLR P1.2; make SCK low

CLR P1.3; Chip select CS valid

MOV A, #06H; WREN instruction sends accumulator A

LCALL WD-OUTB ; Output WREN instruction

SETB P1.3; Make CS high

CLR P1.3; Chip select CS valid

MOV A, #01H; WRSR instruction sends accumulator A

LCALL WD-OUTB; Output WRSR instruction, set status register

MOV A, #10H; no block protection, timeout period; 800ms

LCALL WD-OUTB ;Output status register content

CLR P1.2; Make SCK low

SETB P1.3; Make CS high

RET ;

e. Read storage unit content subroutine

To read the contents of a specified unit from the serial EEPROM of the X25165, you need to send a READ instruction and a 16-bit address first. The data of the specified address unit will be shifted out from the S0 pin in sequence under the action of the SCK pulse.

WD-RD-DATA: CLR P1.2; make SCK low

CLR P1.3; Chip select CS valid

MOC A, #03H; READ instruction sends accumulator A

LCALL WD-OUTB; output READ instruction

MOV A, DPH; high address is sent to accumulator A

LCALL WD-OUTB ;output high address

MOV A, DPL; low address sent to accumulator A

LCALL WD-OUTB ;output low address

LCALL WD-INB ;Read the data of (DPTR) unit

MOV R4, A; data is sent to R4

LCALL WD-INB ;Read the data of (DPTP+1) unit

MOV R5, A; data is sent to R5

CLR P1.2; Make SCK low

SETB P1.3; Chip select CS is invalid

RET

f. Write storage unit content subroutine

This subroutine writes data to the specified starting address of the EEPROM in the chip. Like the write status register subroutine, the program needs to output the WREN instruction to set the write enable latch. Then, the 16-bit address stored in DPTR and the 16-bit data stored in R5 and R4 are output in the order of high bit first. Finally, the WIP bit of the status register is cyclically checked until the write operation of the core content is completed to ensure that the data is written to the chip safely and reliably.

WD-WR-DATA: CLR P1.2; make SCK low

CLR P1.3; Chip select CS valid

MOV A, #06H; WREN instruction sends accumulator A

LCALL WD-LUTB ; Output WREN instruction

SETB P1.3; Make CS high

CLR P1.3; Chip select CS valid

MOV A, #02H; WRITE instruction sends accumulator A

LCALL WD-OUTB ; Output WRITE instruction

MOV A, DPH; output high 8 bits of address

LCALL WD-OUTB;

MOV A, DPL; output low 8 bits of address

LCALL WD-OUTB;

MOV A, R4; output low 8 bits of data

LCALL WD-OUTB;

MOV A, R5; output high 8 bits of data

LCALL WD-OUTB;

CLR P1.2; Make SCK low

SETB P1.3; Make CS high

WD-WIP-POLL: LCALL WD-RD-SR; Read status register

JB ACC.0, WD-WIP-POLL

; Check WIP position

RET

g. Watchdog timer reset subroutine

As long as the subroutine is executed within the set watchdog timer timeout period and a falling edge is sent to the CS pin of the chip, the watchdog will not generate a reset output signal.

WD-EAT: SETB P1.3;

CLR P1.3; Generate CS falling edge pulse

SETB P1.3 ;

RET

The author used the X25165 chip when designing the wheel diameter axial displacement detector, which simplified the system structure, reduced costs, and improved system reliability. The data saved during use has never been lost, and the results are satisfactory.

Keywords:MCU  Watchdog  X25165 Reference address:Application of X25165 chip in 8051 system

Previous article:Application of LCD display module with built-in SED1335 controller and single chip microcomputer interface
Next article:Design of OLED display scheme using C8051F023 single chip microcomputer

Recommended ReadingLatest update time:2024-11-16 23:44

AVR MCU timer 0 compare match function test TIME0_CTC
/*Don't talk nonsense*/ /*Test the compare match function of AVR timer 0*/ #include iom16v.h #define uchar unsigned char #define uint unsigned int #define set_bit(a,b) a|=(1 b) #define clr_bit(a,b) a&=(1 b) #define get_bit(a,b) a&(1 b) #pragma interrupt_handler time0ctc_isr:20 void time0ctc_isr()//Timer counter 0 c
[Microcontroller]
PIC16-bit microcontroller CAN (5) interrupt
The reception of CAN data is handled using interrupts. The ECAN module generates three different interrupts, each with its own interrupt vector, interrupt enable control bit, interrupt status flag, and interrupt priority control bit. These interrupts are: ? CiTX——ECAN sends data request ? CiRX——ECAN receive data rea
[Microcontroller]
A brief talk about the feelings of two months of single chip microcomputer design and development
When I wrote this article, my two-month microcontroller design and development had already ended. I felt quite emotional, so I wrote this article. First of all, let me introduce to you what a single-chip microcomputer is. The full name of a single-chip microcomputer is "single-chip microcomputer", and its English na
[Microcontroller]
Research on software design of brain wave therapeutic instrument based on single chip microcomputer
O Introduction According to the research of modern electrophysiological neuropsychology, brain wave activity is mainly divided into four groups of patterns according to specific wavelengths: β, α, θ, and δ. A certain pattern of brain wave activity is associated with a specific mental state. The brain wave therapy dev
[Microcontroller]
Research on software design of brain wave therapeutic instrument based on single chip microcomputer
PIC microcontroller (PIC16F15323) environment construction
You need to install two software, MPLAB X IDE v5.50 and xc8-v2.32-full-install-windows-x64-installer For simulation, you can also install proteus software 1 Installation of MPLAB X IDE v5.50 Software download link: https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide#tabs After download
[Microcontroller]
PIC microcontroller (PIC16F15323) environment construction
51 MCU: 8x8 dot matrix displays heart-shaped pattern
The MCU development board is made by myself. The circuit is very simple. The rows and columns of the 8*8 dot matrix are connected to the P0 and P1 ports of the MCU respectively. Remember to use a pull-up resistor on the P0 port. I tested it successfully, see the picture. #include reg52.H unsigned ch
[Microcontroller]
51 MCU: 8x8 dot matrix displays heart-shaped pattern
Application of PIC16LF874 single chip microcomputer in capacitance measurement module
Abstract: In order to improve the accuracy of capacitance measurement, a capacitance measurement module based on the PICl6LF874 single-chip microcomputer is designed according to the working principle of the capacitive sensor. The application background and current research status of the capacitance measurement circ
[Industrial Control]
Application of PIC16LF874 single chip microcomputer in capacitance measurement module
Design of mobile power supply based on MC32P21 microcontroller
A mobile power bank is a portable charger that integrates power supply and charging functions. It can charge or power standby for mobile phones and other digital devices anytime and anywhere. It usually uses lithium batteries or dry batteries as power storage units. Different from the battery configured inside the pro
[Power Management]
Design of mobile power supply based on MC32P21 microcontroller
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号