Virtual I2C bus software package VIIC_M1.0 based on MSP430 microcontroller

Publisher:自由思考Latest update time:2012-06-27 Source: 北京工业大学 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Reference address:Virtual I2C bus software package VIIC_M1.0 based on MSP430 microcontroller

Previous article:Simple digital frequency meter based on DSP2812
Next article:MSP430 series microcontroller issues

Recommended ReadingLatest update time:2024-11-16 15:40

Interpretation of the reversing radar system circuit designed with MSP430F2274 microcontroller
  With the increasing demand for intelligent vehicle assisted driving systems and the development of automotive electronic systems, new reversing radars should be able to continuously measure and display the distance to obstacles, and have communication functions to send data to the vehicle bus. Previous reversing rad
[Power Management]
Interpretation of the reversing radar system circuit designed with MSP430F2274 microcontroller
Design of low power consumption electronic thermometer based on MSP430F microcontroller
  The thermometer has an electronic clock, a detection range of 10℃~30℃, a detection resolution of 1℃, an LCD display, and a static power consumption of 0.5μA. Its system design concept also has a certain reference value for the research and development of other types of ultra-low power consumption micro-portable inte
[Microcontroller]
Design of low power consumption electronic thermometer based on MSP430F microcontroller
Design of intelligent network water meter reading system based on MSP430 single chip microcomputer
With the development of electronic communication and computer network technology, remote meter reading technology has been promoted and applied in water, electricity and gas metering. In order to adapt to this development direction, on the basis of developing wired remote water meters and their data collectors, a de
[Microcontroller]
Design of intelligent network water meter reading system based on MSP430 single chip microcomputer
MSP430 microcontroller framework program
The framework program of MSP430 microcontroller (transferred) The program framework of MSP430 is given below, on this basis we can modify and add the programs we need. /********************************************************************************\ File name: main.c Description: MSP430 framework program. Appli
[Microcontroller]
Summary of MSP430 MCU Development
1.#i nclude<> means to go to the editor setting directory, #i nclude "" means to go to the current project directory. 2. To call a function in another file, put the function file in the current project directory and add it to the project. 3. There cannot be a - in the name, for example: byq-ee will be considered wron
[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号