stm32f4硬體週邊介紹

26
STM32F407 硬體週邊介 (JackABK) 2014/09/04 [email protected] 超威猛應輔具特隊

Upload: jack-wang

Post on 01-Dec-2014

1.096 views

Category:

Engineering


6 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Stm32f4硬體週邊介紹

STM32F407 硬體週邊介紹

⺩王尹⾠辰(JackABK) 2014/09/04

[email protected]

超威猛應⽤用輔具特⼯工隊!

Page 2: Stm32f4硬體週邊介紹

GPIO

Page 3: Stm32f4硬體週邊介紹

GPIO(General Purpose Input/Output)

• GPIO is a generic pin on a chip whose behavior !

including whether it is an input or output pin) can be controlled (programmed) by the user at run time.

Page 4: Stm32f4硬體週邊介紹

GPIO Input

• Floating

unknown voltage input stage

• Pull-up

connect to high voltage

• Pull-down

connected to ground

Page 5: Stm32f4硬體週邊介紹

Input configuration

Page 6: Stm32f4硬體週邊介紹

GPIO Output

• push pull

pull-up

pull-down

• open-drain

pull-up

pull-downPull-down

Page 7: Stm32f4硬體週邊介紹

Output configuration

Page 8: Stm32f4硬體週邊介紹

Setting GPIO pins• You can configure on the corresponding peripheral:

Speed

Mode

Type

Pull up/pull down resistors

Page 9: Stm32f4硬體週邊介紹

Setting GPIO pins• On the STM32F4xx the GPIO ports are connected

to the AHB1 bus

• Enabling the clock:

Page 10: Stm32f4硬體週邊介紹

Setting GPIO pins• The GPIO’s clock can be anything of the following:

• GPIO_Speed_2MHz

GPIO_Speed_25MHz

GPIO_Speed_50MHz

GPIO_Speed_100MHz

Page 11: Stm32f4硬體週邊介紹

Setting GPIO pins• On the STM32F4 the GPIO can have up to 4 modes

GPIO_Mode_OUT for digital output

GPIO_Mode_IN for digital input

GPIO_Mode_AN for analog input

GPIO_Mode_AF for the alternate functions (like SPI, I²C, USART, …)

Page 12: Stm32f4硬體週邊介紹

Setting GPIO pins• For the gpio output, The type indicates the

hardware configuration of the pin which can be:

GPIO_OType_PP, !

• a push-pull is driving the output

GPIO_OType_OD!

• the output is open-drain

Page 13: Stm32f4硬體週邊介紹

Setting GPIO pins•Next we can configure pull up, pull down resistors or nothing at all for each pin:!

•GPIO_PuPd_NOPULL no resistor connected

•GPIO_PuPd_UP pin is connected to a pull up resistor

•GPIO_PuPd_DOWN pin is connect to a pull down resistor

Page 14: Stm32f4硬體週邊介紹

Setting GPIO pinsThe resistors value of Pull-up and Pull-down

Page 15: Stm32f4硬體週邊介紹

Setting GPIO pins•A complete of code to set the gpio pin:

Page 16: Stm32f4硬體週邊介紹

Interrupt

Page 17: Stm32f4硬體週邊介紹

Interrupt Structure

Page 18: Stm32f4硬體週邊介紹

Interrupt Structure

Page 19: Stm32f4硬體週邊介紹

Interrupt handler• On way to achieve this goal consists in the creation of

tasks waiting for an interrupt to occur with a semaphore. !• Let this safer portion of code actually handle the interrupt.

An ISR “gives” a semaphore and unblock a ’Handler” task that is able to handler the ISR, making the ISR execution much shorter

Page 20: Stm32f4硬體週邊介紹

Nested Vectored Interrupt Controller (NVIC)

• Depending on the implementation used by the silicon manufacturer.

• The NVIC can support up to 240 external interrupts with up to 256 different priority levels(0 to 255) that can be dynamically reprioritized.

PreemptionPriority: 4bits

SubPriority: 4bits

Page 21: Stm32f4硬體週邊介紹

External Interrupt(EXTI)•Before settings EXTI, You must be:

connected from GPIO settings EXTI 設定哪條Line

• Interrupt mode • interrupt condition?(Rising, Falling, Rising&falling ) • LineCmd( ENABLE is open,DISABLE is close.)

settings NVIC • IRQ_Channel • PreemptionPriority and SubPriority • ChannelCmd

Page 22: Stm32f4硬體週邊介紹

External Interrupt(EXTI)

Page 23: Stm32f4硬體週邊介紹

External Interrupt(EXTI)

The hardware of controller EXTI (blue boxes are registers, red dots are input pins)

Page 24: Stm32f4硬體週邊介紹

External Interrupt(EXTI)for example

Page 25: Stm32f4硬體週邊介紹

Ref.!

• STM32F4 GPIO Configuration

• NCKU wiki

• Interrupts & ports

Page 26: Stm32f4硬體週邊介紹

Thanks!