0% found this document useful (0 votes)
5 views28 pages

L12 - Ascending Stack and Pin Connect Block

The document discusses the use of stack operations in ARM architecture, specifically the LDM and STM instructions for efficiently saving and restoring multiple registers. It also describes the pin connect block of a microcontroller, detailing how pins are configured for different functions and the importance of mapping peripherals to the correct pins. Additionally, it includes examples of stack operations and pin configuration for controlling LEDs.

Uploaded by

mainahibataunga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views28 pages

L12 - Ascending Stack and Pin Connect Block

The document discusses the use of stack operations in ARM architecture, specifically the LDM and STM instructions for efficiently saving and restoring multiple registers. It also describes the pin connect block of a microcontroller, detailing how pins are configured for different functions and the importance of mapping peripherals to the correct pins. Additionally, it includes examples of stack operations and pin configuration for controlling LEDs.

Uploaded by

mainahibataunga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

L12: Stack and Pin

connect blocks
Stack
• Using LDM and STM instructions for the stack
• In many interrupt and multitasking applications we need to save the
contents of multiple registers on the stack and restore them back.
• Pushing the registers onto the stack one register at a time is time
consuming.
• For this reason ARM has the STM and LDM instructions.
• The STM and LDM allow to store (push) and load (pop) multiple registers
with a single instruction
• Two types
• Full Ascending Stack and Full Descending Stack
• Full Ascending Stack
• STM
• STM R11,{R0-R3}; Store R0 through R3 onto memory pointed to by
R11
• LDM
• LDM R8,{R0-R7}; Load R0 through R7 from memory pointed to by R8
• Full Descending Stack
• STMDB
• LDMDB
• Example
• ldr r13,=0x10001000
• ldr r0,=0x12345678
• ldr r1,=0x87654321
• ldr r2,=0x45678ab9
• ldr r3,=0x9ba87654

• push {r0,r1,r2}

• stm r13, {r0,r3,r2}


• pop {r3}
• pop{r1}
• pop{r2}
• stmdb r13!,{r2,r3}
• pop{r0,r1}

• stop b stop
• Example
• ldr r13,=0x10001000
• ldr r0,=0x12345678
• ldr r1,=0x87654321
• ldr r2,=0x45678ab9
• ldr r3,=0x9ba87654

• push {r0,r1,r2}

• stm r13, {r0,r3,r2}


• pop {r3}
• pop{r1}
• pop{r2}
• stmdb r13!,{r2,r3}
• pop{r0,r1}

• stop b stop

• end
ldr r13,=0x10001000
ldr r0,=0x12345678
ldr r1,=0x87654321
ldr r2,=0x45678ab9
ldr r3,=0x9ba87654

push {r0,r1,r2}

stmdb r13, {r0,r3,r2}


pop {r3}
pop{r1}
pop{r2}
stm r13!,{r2,r3}
pop{r0,r1}

stop b stop

end
Pin connect Block
• Pin Configuration

• All the Pins are divided among 5 Ports


• Port 0 (P0) to Port 4 (P4)
• Length of each port is 32 bits
• Named as P0.0 to P0.31 for port 1………. and P4.0 to P4.31 for port 4
Pin connect block
Pin connect Block

• The pin connect block allows most pins of the microcontroller to have
more than one potential function
• Configuration registers control the multiplexers to allow connection
between the pin and the on chip peripherals
• Peripherals should be connected to the appropriate pins prior to being
activated and prior to any related interrupt(s) being enabled.
• Activity of any enabled peripheral function that is not mapped to a
related pin should be considered undefined
• Selection of a single function on a port pin excludes other peripheral
functions available on the same pin
• However, the GPIO input stays connected and may be read by software
or used to contribute to the GPIO interrupt feature.
• Pin function select register values
• The PINSEL registers control the functions of device pins
• Assume 8 LEDs are connected to P0.0 to P0.7. Configure the port PINs
to GPIO and turn On and OFF the LEDs continuously .

You might also like