chapter 14 arm gpio (general purpose input/output)€¦ · arm gpio (general purpose input/output)...

17
Chapter 14 ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018

Upload: others

Post on 04-Jul-2020

52 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

Chapter 14 ARM GPIO

(General Purpose Input/Output)

Embedded Systems with ARM Cortex-M

Updated 3/6/2018

Page 2: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

Board IO Pins

Page 3: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

GPIO Pins

• Flexibility due to limited amount of pins on the board.

• Can be configured as 4 types:

- Digital INPUT

- Digital OUTPUT

- Analog INPUT (ADC)/OUTPUT (DAC)

- Alternate Function (USART)

Page 4: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

I/O Electronics

Page 5: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

Digital OUTPUT

Page 6: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

Digital INPUT

Page 7: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

Analog IN/OUT

Page 8: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

Alternate Function

Page 9: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins
Page 10: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

All pins are configured in SW!

• By default all peripherals are not clocked. You must enable the clock to each peripheral you wish to use.

• You must then READ the datasheet and find out which registers need to be changed to get desired configuration.

Page 11: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

Memory Map of

STM32F401

Page 12: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

Peripheral Registers

Page 13: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins
Page 14: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins
Page 15: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

Steps to set up Digital OUTPUT

• Provide CLOCK to the port

• Configure the desired I/O as OUTPUT or INPUT in the GPIOx_MODER register

• View the RESET values for the other registers that control I/O and change if necessary:

- GPIOx_OTYPER – Open-Drain/Push-Pull

- GPIOx_OSPEEDR – Low/Med/High Speed

- GPIOx_PUPDR – (Weak) P/U, P/D, None

Page 16: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

Calculating Delay Loop

• Desired delay time = 500ms

• Clock Frequency = 10MHz (Prove it)

• 10*10 ^6 (cycles/second) * 500 * 10^-3 seconds = 40000000 cycles

• Instructions in loop?

Page 17: Chapter 14 ARM GPIO (General Purpose Input/Output)€¦ · ARM GPIO (General Purpose Input/Output) Embedded Systems with ARM Cortex-M Updated 3/6/2018 . Board IO Pins . GPIO Pins

Board Schematic