Connecting devices with different bit widths
Let's first look at how the peripheral ROM is connected to the CPU address bus in the 2440 chip manual.
Connection between 8bit ROM and CPU address line
Connection between 8bit*2 rom and CPU address line
Connection between 8bit*4 rom and CPU address line
Connection between 16bit ROM and CPU address line
Connection between 16bit*2 rom and CPU address line
From the above figure, we know that two 8-bit peripherals can be cascaded to form a 16-bit peripheral. Similarly, four 8-bit peripherals can be cascaded to form a 32-bit peripheral.
From the above figure, we can also see a pattern:
When the peripheral bus width is 8 bits, peripheral A0 is connected to the CPU address bus ADDR[0]. A[1]->ADDR[1] ...A[15]->ADDR[15] When the peripheral bus width is 16 bits, peripheral A0 is connected to the CPU address bus ADDR[1]. A[1]->ADDR[2] ...A[15]->ADDR[16] When the peripheral bus width is 32 bits, peripheral A0 is connected to the CPU address bus ADDR[2]. A[1]->ADDR[3] ...A[15]->ADDR[17]
So why is it designed like this?
Let's look at an example: Assume the CPU executes:
MOV R0, #3 LDRB R1, [R0] @ Read a byte from memory address 3
As shown in the figure, there are 8bitROM, 16bitROM, 32bitROM
(1) For 8-bit ROM, 8 bits is the smallest unit of reading and writing at one time, that is, address 0 is the first 8 bits, and address 1 is the second 8 bits;
The CPU sends address 3, that is, A0 and A1 are both 1, and the 8-bit ROM's A0 and A1 also receive 1.
So we found the 8-bit data at address 3 on the ROM, which contains the data we need.
(2) For 16-bit ROM, 16 bits is the smallest unit of reading and writing at one time, that is, address 0 is the first 16 bits, which contains two 8-bit data;
The CPU sends address 3, that is, A0 and A1 are both 1, and the 16-bit ROM receives 1 and 0 respectively.
So we find the 16-bit data at address 1 on the ROM, which contains the data we need. Finally, the memory controller helps us select the required 8-bit data.
(3) For 32-bit ROM, 32 bits is the smallest unit of reading and writing at one time, that is, address 0 is the first 32 bits, which contains four 8-bit data;
The address 3 sent by the CPU, that is, A0 and A1 are both 0, and the A0 and A1 received by the 32-bit ROM are both 0.
So we find the 32-bit data at address 0 on the ROM, which contains the data we need. Finally, the memory controller helps us select the required 8-bit data.
Use a table to understand better:
ROM/bit | The CPU issues an address | ROM received address | ROM returns data | The memory controller selects data and sends it to the CPU |
---|---|---|---|---|
8bit(ROM) | 0b000011 | 0b000011 | Data 8 in memory cell number 3 | Data 8 in memory cell number 3 |
16bit(ROM) | 0b000011 | 0b000001 | The 16 data in the memory cell number 1 | According to "A0=1", pick out the lower 8 bits of data |
32bit(ROM) | 0b000011 | 0b000000 | The 32 data in the memory cell number 0 | According to "A1A0=11", pick out the lowest 8 bits of data |
in conclusion:
The peripheral address lines connected to the CPU address bus determine the address of the peripheral to be accessed, that is, which storage unit;
Then, after the memory controller obtains the data from the peripheral storage unit, it selects the corresponding data for the CPU based on the values of the staggered pins [A1-A0] (the values of the pins not connected to the CPU address bus).
Let's take another example: If you read a 32-bit data
MOV R0, #4
LDR R1, [R0] @Go to address 4, read 4 bytes of data
We know that the CPU issues a 32-bit address, so
For 16-bit Rom, the memory controller will send it twice, and the ROM will receive it twice accordingly;
For 8-bit Rom, the memory controller sends it 4 times, and the ROM receives it 4 times.
So how does the CPU know whether the bit width of its external ROM is 16bit, 8bit or something else?
Of course the memory controller knows and configures the bus width register. How to configure the bus width register
The execution process is as follows:
ROM/bit | The CPU issues an address | ROM receives the address (memory controller forwards to ROM) | ROM returns data | The memory controller assembles data for the CPU |
---|---|---|---|---|
8bit(ROM) | 0b000100 | 0b000100 | A 1-byte data at address 4 | Assemble address 7, 6, 5, 4 data into 4 bytes |
|
|
0b000101 | A 1-byte data at address 5 |
|
|
|
0b000110 | A 1-byte data at address 6 |
|
|
|
0b000111 | A 1-byte data at address 7 |
|
16bit(ROM) | 0b000100 | 0b00010 | A 2-byte data at address 2 | Assemble the data at address 3 and 2 into 4 bytes |
|
|
0b00011 | A 2-byte data at address 3 |
|
32bit(ROM) | 0b000100 | 0b00001 | A 4-byte data at address 1 | Directly return 4 bytes of data |
How to determine the access address of the chip?
1. Determine the base address based on the chip select signal 2. Determine the range based on the address lines connected to the chip
Peripheral Type | Which chip select of the memory controller is connected | Base Address | Occupies the CPU's address bus | Address range (offset + size) |
---|---|---|---|---|
nor | nGCS0 | 0x0000,0000 | ADDR0-ADDR20 | 0x0000,0000 ~ 0x001f,ffff(2M) |
DM9000 network card | nGCS4 | 0x2000,0000 | ADDR0 and ADDR2 | 0x2000,0000 ~ 0x2000,0005(5byte) |
sdram | nGCS6 | 0x3000,0000 | ADDR0-ADDR25 | SDRAM address range |
Here is another reminder, some people found that nor is not connected to CPU ADDR0, and sdram is not connected to CPU ADDR0 and ADDR1. Don't think that ADDR0 and ADDR1 are not used, because nor data width is 16 bits, ADDR0 is used for memory controller to split data, and sdram data width is 32 bits, ADDR0 and ADDR1 are also used for memory controller to split data. This has been analyzed above, and this is why the misaligned connection is required.
Previous article:s3c2440 bare metal - memory controller 3 - SDRAM principle - how does the CPU access sdram
Next article:s3c2440 bare metal - memory controller 1 - the principle of memory controller
Recommended ReadingLatest update time:2024-11-16 09:50
- Popular Resources
- Popular amplifiers
- Siemens PLC Programming Technology and Application Cases (Edited by Liu Zhenquan, Wang Hanzhi, Yang Kun, etc.)
- Siemens PLC from Beginner to Mastery with Color Illustrations (Yang Rui)
- Experience and skills in using Siemens S7-200PLC (Shang Baoxing)
- Siemens S7-1200-PLC Programming and Application Tutorial (3rd Edition) (Edited by Shi Shouyong)
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
- Cumulative error analysis and clock frequency optimization for UART communication in MSP430FR2311
- Learn 3D visualization from scratch: Exploded diagram
- 1000m WIFI amplifier ~ Anyone interested?
- FilterSolutions User's Guide The simulated filter that has been practiced is pretty good
- What is the definition of these so-called self-organizing networks?
- dsp6657 serial port learning
- Try the data visualization tool of visionseed in Ubuntu
- Help with AD9 package design
- 1. Unboxing and Review
- NXP PLC2366 Timer 2 Interrupt Program