The S3C2440A RISC microprocessor can support a multi-master IIC bus serial interface. A dedicated serial data line (SDA) and a dedicated
serial clock line (SCL) pass information between the bus master and the peripherals connected to the IIC bus. Both the SDA and SCL lines are bidirectional.
In multi-master IIC bus mode, multiple S3C2440A RISC microprocessors can send or receive serial data from or to slave devices. The master
S3C2440A can start and end data transfers through the IIC bus. The IIC bus in the S3C2440A uses standard bus arbitration procedures.
To control the multi-master IIC bus operation, values must be written to the following registers:
– Multi-master IIC bus control register, IICCON
– Multi-master IIC bus control/status register, IICSTAT
– Multi-master IIC bus Tx/Rx data shift register, IICDS
– Multi-master IIC bus address register, IICADD
When releasing the IIC bus, both the SDA and SCL lines should remain high. A high-to-low SDA transition initiates a start condition.
A low-to-high SDA transition while SCL remains stable at a high level initiates a stop condition.
The start and stop conditions are usually generated by the master device. The first data byte is the 7-bit address value, which is placed on the bus after the start condition is initiated to determine
the slave device that the master device wants to select. The 8th bit determines the direction of the transfer (read or write).
Each byte placed on the SDA line should have a total of 8 bits. Bytes can be sent or received without restriction during the bus transfer operation. Data is usually
sent most significant bit (MSB) first, and each byte should be immediately followed by an acknowledge (ACK) bit.
The I2C bus can form a multi-master and multi-slave system. In a multi-master system structure, the system obtains the right to control the bus through hardware or software arbitration. In the application system, the I2C bus mostly adopts a master-slave structure, that is, there is only one master node on the bus, and the other devices on the bus are slave devices. The device addressing on the I2C bus is determined by the device address wiring, and the read/write direction is controlled by accessing the lowest bit of the address.
At present, most general-purpose memory chips are EEPROM, and their commonly used protocols are mainly two-wire serial connection protocol (I2C) and
Three-wire serial connection protocol. There are many types of EEPROMs with I2C bus interface, among which AT24CXX series is very popular. Products include AT24C01, AT24C02, AT24C04, AT24C08, AT24C16, etc.
AT24 series memory chips are manufactured using CMOS technology and have a built-in boost circuit, which allows them to work under single voltage supply conditions. The standard package is an 8-pin DIP package.
The functions of each pin are described as follows:
SCL: Serial clock. Follows ISO/IEC7816 synchronization protocol, open drain, requires pull-up resistor. On the rising edge of this pin, the system inputs data to each EEPROM device and outputs it on the falling edge.
SDA: Serial data line. Open drain, need to connect pull-up resistor. Bidirectional serial data line, open drain, can be wired-OR with other open devices.
A0, A1, A2: Device/page address input terminals. In AT24C01 and AT24C02, the pins are hard-wired, and other AT24Cxx can be connected to the address lines.
WP: Read/write protection. When connected to a low level, the entire space can be read/written, and when connected to a high level, it cannot be read/written and is protected.
Vcc/GND: 5V operating voltage.
Device Address (DADDR)
AT24CXX data operation format
In the I2C bus, to read/write the internal storage unit of AT24C04, in addition to giving the device address (DADDR) of the device
In addition, the page address (PADDR) for reading/writing must be specified. The two together make up the operation address (OPADDR) as follows:
The following is a description of IIC from someone else's article, which is very well written.
There is an IIC bus interface inside the s3c2440, so it is convenient for us to connect peripheral devices with IIC communication modules. It has four operating modes: master device sending mode, master device receiving mode, slave device sending mode and slave device receiving mode. Here we only use the s3c2440 as the master device of the IIC bus, so only the first two operating modes are introduced. In the master device sending mode, its workflow is: first configure the IIC mode, then write the slave device address into the receive and send data shift register IICDS, and then write 0xF0 into the control status register IICSTAT, then wait for the slave device to send a response signal. If you want to continue sending data, then after receiving the response signal, write the data to be sent into the register IICDS, clear the interrupt flag, and wait for the response signal again; if you don’t want to send data anymore, then write 0x90 into the register IICSTAT, clear the interrupt flag and wait for the stop condition, and the master device has completed the transmission. In the master device receiving mode, its workflow is: first configure the IIC mode, then write the slave device address into the receive and send data shift register IICDS, and then write 0xB0 into the control status register IICSTAT. At this time, wait for the slave device to send a response signal. If you want to receive data, then read the register IICDS after the response signal to clear the interrupt flag; if you don't want to receive data, then write 0x90 to the register IICSTAT, clear the interrupt flag and wait for the stop condition, and then the master device reception is completed. When completing the above two modes, the control register IICCON, the control status register IICSTAT and the send and receive data shift register IICDS are mainly used. Since we only use s3c2440 as a master device, and there is only one master device on the IIC bus of the system, the address register IICADD used to set the slave device address and the multi-master device line control register IICLC used for arbitration bus do not need to be configured. The 6th bit and the lower 4 bits of the register IICCON are used to set the clock frequency of IIC, because the clock line SCL of IIC is provided by the master device. The IIC clock source of s3c2440 is PCLK. When the system PCLK is 50MHz and the slave device requires a maximum of 100kHz, the 6th bit of IICCON can be set to 1, and the lower 4 bits of IICCON can be all 0. The 7th bit of register IICCON is used to set whether to send a response signal, the 5th bit is used to enable sending and receiving interrupts, and the 4th bit is used for the interrupt flag. After receiving or sending data, this bit must be cleared to clear the interrupt flag. The upper 2 bits of register IICSTAT are used to set which operation mode is used. When writing 0 or 1 to the 5th bit, it means ending IIC or starting IIC communication. The 4th bit is used to enable receiving/sending data.
The following is a program analysis using the FL2440 development board:
#include
#include "2440addr.h"
#include "def.h"
#include "IIC.h"
static U8 _iicData[IICBUFSIZE];
static volatile int _iicDataCount;//Send count flag
static volatile int _iicStatus;//IIC status flag
static volatile int _iicMode;//IIC mode flag
static int _iicPt;
extern void Uart_Printf(char *fmt,...);
extern void Uart_Init(int baud);
void Delay(int x);
//================================================ ===================
//
//
//
//====== ================================================== ===========
//******************[Test_Iic]****************************** ***********
void Test_Iic(void)
{
}
[page]
//*************************[ Wr24C080 ]********************************
void Wr24C080(U32 slvAddr,U32 addr,U8 data)//First address
{
}
//**********************[ Rd24C080 ] ***************************************
void Rd24C080(U32 slvAddr,U32 addr, U8 *data) //The address where the data read from the first internal address is stored
{
}
//-------------------------------------------------------------------------
void __irq IicInt(void)
{
//
}
void Delay(int x)
{
}
Previous article:STM32 general-purpose timer (TIM2-5) PWM output
Next article:11 ARM9 (2440) network card interface expansion
Recommended ReadingLatest update time:2024-11-16 10:51
- Popular Resources
- Popular amplifiers
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
- Want to learn about switching power supplies? Start by reading this book!
- Practical Application Skills of DC Motors
- Minimalist USB TYPE-C PD3.0/3.1 spoof trigger solution
- [Synopsys IP Resources] Using the ARC SEM130FS processor to meet the safety protection requirements of new automotive SOCs
- 【MicroPython】Using MCO as a clock
- Good news! Owning an ultra-high performance UXR series oscilloscope is no longer a dream!
- Gallium Nitride—Not Just for Defense Anymore
- Solution design: an electronic smart lock with integrated Wi-Fi
- SVPWM source code and comments
- [STM32F769Discovery development board trial] Serial port idle interrupt indefinite length reception & PWM output square wave