Cbn new ldr to bank
A low-level programming question!
When a new leader (ldr) is loaded into the bank, it means that a new program or code is being executed from a specific memory location. Here's a breakdown of the process:
- Bank selection: The microcontroller (MCU) selects a specific bank of memory, which is a contiguous block of memory addresses. Each bank typically has its own dedicated memory space.
- Leader loading: The MCU loads a new leader (ldr) into the selected bank. The leader is a small piece of code that sets up the memory space and prepares it for execution.
- Program counter update: The program counter (PC) is updated to point to the starting address of the new leader in the selected bank.
- Execution: The MCU starts executing the new leader code, which initializes the memory space, sets up registers, and prepares the MCU for executing the main program.
In some microcontrollers, the leader is also referred to as the "bootloader" or "initialization code." Its primary function is to initialize the MCU's hardware and software components, such as setting up the memory map, configuring peripherals, and initializing the stack.
When a new leader is loaded into the bank, it typically involves the following steps:
- The MCU reads the leader code from external memory (e.g., flash memory) or internal memory (e.g., ROM).
- The leader code is executed, which initializes the MCU's hardware and software components.
- The leader code sets up the memory space, including the stack and heap.
- The leader code configures peripherals, such as UART, SPI, or I2C interfaces.
- The leader code initializes any necessary variables or data structures.
- The leader code sets up the program counter to point to the starting address of the main program.
After the leader is loaded and executed, the MCU is ready to execute the main program, which is typically stored in a different memory bank or region.