1. Composition of VIIC_M1.0 software package
According to the requirements of normalized design, the virtual I2CC bus in master mode consists of the following 10 subroutines:
1. Timing simulation subroutines 4
I2C_sta, I2C _stop, I2C _mack, I2C _mnack
2. Operation simulation subroutines 3
I2C_ackn, I2C _wr_byte, I2C _rd_byte
3. Data read and write subroutines 3
I2C_wr_nbyte, I2C _rd_nbyte, I2C_wr_addr
2. Application Objects
1. MSP430 MCU
The MSP430 MCU is a low-power 16-bit MCU, including MSP430X11, MSP430X112, MSP430X1101, MSP430X13X, MSP430X14X, MSP430X31X/32X/33X, MSP430X41X, etc. Each chip has rich I/O ports. The chip used in this design is MSP430E325
(1) The I/O port used by the virtual I2C bus
> The data line (SDA) uses P0.7 in the general port P0. This port is an input/output bidirectional port, with input register (P0IN), output register (P0OUT) and direction register (P0DIR) registers, which are accessed through byte instructions. >>The clock line (SCL) uses TP.1 in the general timer/port TP. This port is an output port, which has a timer/port control register (TPCTL), a timer/port data register (TPD), and a timer/port enable register (TPE), etc., which are accessed through byte instructions.
(2) Clock frequency used during operation
The MSP430E325 uses two clocks during operation: the auxiliary clock (ACLK) and the main clock (MCLK). When a 32768KHz crystal oscillator is used and the system clock control register uses the default value, the frequency of the main clock is 1.049MHz. If the frequency of the main clock is not 1.049MHz, please adjust the number of nops in the program appropriately.
2. EEPROM device
(1) EEPROM device
The EEPROM device used in this example is 24LC65 (MICROCHIP). The capacity of 24LC65 is 8KB, of which the byte address is 13 bits, divided into two bytes:
SUBADDR_H is the high 5-bit address and SUBADDR_L is the low 8-bit address; the package pin of 24LC65 is shown in Figure 1:
(2) Data format of 24LC65
A. Current address write: S, SLA+W, A, DATA1, A, DTA2, A..., DATAn, A, P
B. Current address read: S, SLA+R, A, DATA1, A, DTA2, A..., DATAn, /A, P
C. Specified address write: S, SLA+W, A, subaddr_H, A, subaddr_L, A, DATA1, A, DATA2, A,..., DATAn, A, P
D. Read the specified address: S, SLA+R, A, subaddr_H, A, subaddr_L, A, DATA1, A, DATA2, A, ..., DATAn, /A, P
Where: SLA+W, SLA+R, subaddr_H, subaddr_L is the data sent by the master device
S, A, /A, P is the information sent by the master device
DATA1, DATA2, ..., DATAn is the data sent by the controlled device to the master device
A is the information sent by the controlled device to the master device
(3) The connection between 24LC65 and MSP430-325 is shown in Figure 2 [page]
|
|
Figure 1
|
Figure 2
|
3. Application Interface
1. Send N bytes of data - start from the current address
; the data sent is in MTD
;
; Sequence format: S, SLA+W, subaddr_H, A, subaddr_L, A, DATA1, A, DATA2, A..., DATAn, A, P
; MOV.b #CODE, SLA; I2C_R_R/W=0; A0=A1=A2=0
MOV.b #N, Num_byt; send number of bytes
CALL I2C_WR_Nbyte; write from the current address
2. Receive N bytes of data - read from the specified address
; the received data is in MRD
;
; Sequence format: S, SLA+W, A, subaddr_H, A, subaddr_L, A,
S, SLA+R, A, DATA1, A, DATA2, A,..., DATAn, / A, P
MOV.b #CODE+SLAR/W, SLA
; SLAR/W=1, A0=A1=A2=0
MOV.b #N,Num_byt ;Number of bytes received
CALL #I2C_RD_Nbyte ;Read from current address
3. Receive N bytes——Read from specified address
;The received data is stored in MRD
;
;Serial format: S, SLA+W, A, subaddr_H, A, subaddr_L, A,
;S, SLA+R, A, DATA1, A, DATA2, A, ..., DATAn, /A, P
;
MOV.b #CODE, SLA
;SLAR/W=0: write, A0=A1=A2=0
MOV.b #N, Num_byt ;Number of bytes received
MOV #Subaddr, I2C_R_Addr ;Byte address is sent to temporary storage unit
CALL #I2C_R_Addr ;Send byte address
MOV.b #CODE+SLAR/W, SLA ;SLAR/W=1: read, A0=A1=A2=0
CALL #I2C_RD_Nbyte
4. Send N bytes - write from the specified address
; Sequence format: S,SLA+W,A,Subaddr_H,A,subaddr_L,A,DATA1,A,DATA2,A,...,DATAn,A,P
;
MOV.b #CODE, SLA; SLAR/W=0: write, A0=A1=A2=0
MOV #N,Num_byt ; Send the number of bytes
MOV #Subaddr,I2C_R_Addr ; Send the byte address to the temporary storage unit
CALL #I2C_WR_Addr ; Send the byte address
CALL #WR_Nbyte
postscript:
1. If you use other I/O ports in MSP430, you only need to change the corresponding register in the simulation timing subroutine. In this example, the clock line uses the TP port because it is an output port, which can save instructions in the program.
For other chips in the 24 series, due to different capacities, please pay special attention to whether their byte addresses are 1 byte or 2 bytes. The byte address of 24LC65 in this example is 2 bytes.
2. I am a beginner in using the MSP430 series of microcontrollers. Although the program has been initially debugged, it is easily thrown out. The idea is to serve as a reference and a little experience in learning. Shortcomings and errors are inevitable. I hope you will give me your advice.
Previous article:Simple digital frequency meter based on DSP2812
Next article:MSP430 series microcontroller issues
Recommended ReadingLatest update time:2024-11-16 15:40
- Popular Resources
- Popular amplifiers
- MSP430 series single chip microcomputer system engineering design and practice
- Microcontroller Principles and Applications Tutorial (2nd Edition) (Zhang Yuanliang)
- Getting Started and Improving MSP430 Microcontrollers - National Undergraduate Electronic Design Competition Training Course
- Electronic competition thesis documents based on MSP430 microcontroller design + source code and some hardware PCB files
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- The msp430 microcontroller sends floating point numbers to the host computer through the serial port
- MTK7686 serial port transparent transmission
- The amplifier has a high PSRR, so there is no need to worry about power supply variations?
- How to design the mobile phone power-on circuit
- Request expert explanation
- C2000 floating point calculation notes - differences between CPU and CLA and error handling techniques
- EEWORLD University ---- Theoretical basis of IoT terminal development
- Tips for implementing I2C with MSP
- ARM-based support for advanced video graphics capabilities on MCUs
- 12-bit ADC