How to calculate address spaces correctly?

The following is an example of a question asked in my last test on a computer engineering course. Does any mind explain me how to get the start / end addresses of each of them? I have listed the correct answers below ...

The MSP430F2410 has an address space of 64 KB (MSP430 basic architecture). Fill out the table below if we know the following. The first 16 bytes of the address space (starting at 0x0000) are reserved for special function registers (IE1, IE2, IFG1, IFG2, etc.), the next 240 bytes are reserved for 8-bit peripherals, and the next 256 bytes are reserved for 16- bit peripherals. The amount of RAM is 2 KB and starts with the address 0x1100. At the top of the address space is 56 KB of flash memory reserved for code and the interrupt vector table.

  What Start Address End Address
 Special Function Registers (16 bytes) 0x0000 0x000F
 8-bit peripheral devices (240 bytes) 0x0010 0x00FF
 16-bit peripheral devices (256 bytes) 0x0100 0x01FF
 RAM memory (2 Kbytes) 0x1100 0x18FF
 Flash Memory (56 Kbytes) 0x2000 0xFFFF
+4
source share
2 answers

First, do not discard what is stored in each segment, which only confuses you. The problem is simply asking you to determine the numbering of the hexadecimal numbers, and it is not too difficult. Here are the requirements:

  • 64 KB full memory
  • The first 16 bytes of the address space (starting from address 0x0000) is reserved for special function registers (IE1, IE2, IFG1, IFG2, etc.).
  • The next 240 bytes are reserved for 8-bit peripherals
  • The next 256 bytes are reserved for 16-bit peripherals
  • The amount of RAM is 2 KB and starts with the address 0x1100
  • At the top of the address space is 56 KB of flash memory reserved for code and the interrupt vector table.

Since each hexadecimal digit in your memory address can handle 16 values ​​(0-F), you will need 4 digits to display 64 KB of memory (16 ^ 4 = 65536 or 64 KB).

You start with 16 bytes and cover 0x0000 - 0x000F (one full digit of your address). This means that the next segment, which begins immediately after it (8-bit devices), starts at 0x0010 (next byte) and, since it is 240 bytes, ends with byte 256 (240 + 16) or 0x00FF.

The next segment (16-bit devices) starts with the next byte, which is 0x0100 and has a length of 256 bytes, which puts an end to 0x01FF.

Then 2 KB (2048 bytes) of RAM appears, but starts with 0x1100, as the description indicates, and not immediately after the previous segment, so your starting address. Add 2048 to this and you will get 0x18FF.

The last segment covers the upper part of the memory, so you have to work in the opposite direction, you know that it ends with 0xFFFF (the end of the available memory), and it lasts 56 KB. If you convert 56KB to hex, it is 0xDFFF. If you assume that this segment starts at 0, this leaves 2,000 unused (0xE000-0xEFFF and 0xF000-0xFFFF), so you know that this segment must start at 0x2000 to end at the upper end of the memory space.

I hope this becomes clearer, although when I read it I don’t know that it will help at all :( Maybe that's why I will leave teaching this concept to someone more qualified ...

+4
source
#define NUM_SIZES 5 uint16_t sizes[5] = {16, 240, 256, 2 * 1024, 56 * 1024}; uint16_t address = 0; printf("Start End\n"); for (int i = 0; i < NUM_SIZES; i++) { printf("0x%04X 0x%04X\n", address, address + sizes[i] - 1); address += sizes[i]; } 
0
source

Source: https://habr.com/ru/post/1309323/


All Articles