L12 - Ascending Stack and Pin Connect Block
L12 - Ascending Stack and Pin Connect Block
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}
• stop b stop
• Example
• ldr r13,=0x10001000
• ldr r0,=0x12345678
• ldr r1,=0x87654321
• ldr r2,=0x45678ab9
• ldr r3,=0x9ba87654
•
• push {r0,r1,r2}
• stop b stop
• end
ldr r13,=0x10001000
ldr r0,=0x12345678
ldr r1,=0x87654321
ldr r2,=0x45678ab9
ldr r3,=0x9ba87654
push {r0,r1,r2}
stop b stop
end
Pin connect Block
• Pin Configuration
• 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 .