s3c2440 bare metal - memory controller 2 - connection between different bit width peripherals and CPU address bus

Publisher:MysticalSoulLatest update time:2024-07-08 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.


Reference address:s3c2440 bare metal - memory controller 2 - connection between different bit width peripherals and CPU address bus

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

Jlink cannot recognize CPU/lpc2103/lpc2131
Problem description: In the ADS1.2 environment, when using Jlink to connect to Zhou Ligong's EasyARM2131 development board, it prompts that it cannot connect to the CPU (JLINK could not find supported CPU core on JTAG chain). Problem analysis: When using the ZLG template, the FLASH will be encrypted after using the
[Microcontroller]
Samsung releases its first 5nm wearable chip with a built-in low-power "sub-CPU"
On August 10, Samsung Electronics released the Exynos W920, a new generation mobile platform dedicated to wearable devices. It is reported that the Samsung Exynos W920 has an integrated LTE modem and is the industry's first wearable chip using 5nm EUV process. Harry Cho, vice president of LSI system marketing at S
[Semiconductor design/manufacturing]
S3c2440ARM exception and interrupt system detailed explanation 2---CPU mode (Mode) state (State)
In this lesson, we will talk about the CPU's working mode (Mode) and state (State) registers. 7 Modes:  usr (user mode)  sys (system mode)  undefined(und) (undefined mode)  Supervisor (svc) (Manager mode)  Abort (abt) (abort mode)  IRQ(irq) (interrupt mode)  FIQ (fiq) (fast interrupt mode) 2 States:  ARM state  
[Microcontroller]
S3c2440ARM exception and interrupt system detailed explanation 2---CPU mode (Mode) state (State)
Renesas Electronics Launches R-Car Gen3e, Boosting CPU Speed ​​by 20%
Renesas Electronics Corporation, a supplier of semiconductor solutions, announced on July 21 that it has expanded its popular R-Car system-on-chip (SoC) family to include a new product series, R-Car Gen3e. The new SoC family has six new products, creating a scalable lineup for entry-to-mid-range automotive applicati
[Automotive Electronics]
Renesas Electronics Launches R-Car Gen3e, Boosting CPU Speed ​​by 20%
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号