stm32: peripherals - lirmm
TRANSCRIPT
![Page 2: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/2.jpg)
2
System Architecture
![Page 3: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/3.jpg)
3
System Architecture
S0: I-bus: This bus connects the Instruction bus of theCortex-M4 core to the BusMatrix. This bus is used by the coreto fetch instructions. The targets of this bus are the internalFlash memory, the SRAM and the CCM RAM.S1: D-bus: This bus connects the DCode bus (literal loadand debug access) of the Cortex-M4 core to the BusMatrix.The targets of this bus are the internal Flash memory, theSRAM and the CCM RAM.S2: S-bus: This bus connects the system bus of theCortex-M4 core to the BusMatrix. This bus is used to accessdata located in the peripheral or SRAM area. The targets ofthis bus are the SRAM, the AHB to APB1/APB2 bridges, theAHB IO port and the ADC.S3, S4: DMA-bus: This bus connects the AHB masterinterface of the DMA to the BusMatrix which manages theaccess of different Masters to Flash, SRAM and peripherals.
![Page 4: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/4.jpg)
4
Memory map
Peripherals are memory mapped
![Page 5: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/5.jpg)
5
Memory map
![Page 6: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/6.jpg)
6
Memory map
![Page 7: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/7.jpg)
7
Memory map
![Page 8: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/8.jpg)
8
Memory map
![Page 9: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/9.jpg)
9
Reset and clock control (RCC)
System clock (SYSCLK) selection:I HSI clock: generated from an internal 8 MHz RC Oscillator
RCC registers allow to enable the use of a particular peripheralI When the peripheral clock is not active, the peripheral register
values may not be readable by software and the returned valueis always 0x0.
RCC_AHBENR, RCC_APB1RSTR, RCC_APB2RSTR
![Page 10: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/10.jpg)
10
Example: Using on board LEDs
On which bus LEDs are connected?
![Page 11: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/11.jpg)
11
Example: Using on board LEDs
On which bus LEDs are connected? Read DATA SHEET!
![Page 12: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/12.jpg)
12
Example: Using on board LEDs
![Page 13: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/13.jpg)
13
Example: Using on board LEDs
![Page 14: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/14.jpg)
14
Example: Using on board LEDs
We have to use GPIOE connected to bus AHBLet us configure the correct RCC register: RCC_AHBENR
I How to write? (address)I Which value?
![Page 15: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/15.jpg)
15
Example: Using on board LEDs
![Page 16: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/16.jpg)
16
Example: Using on board LEDs
We have to write ‘1’ on the bit 21Address: base + offset
I base = 0x40021000I offset = 0x14I address = 0x40021014
![Page 17: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/17.jpg)
17
Example: Using on board LEDs
Can you write the assembler code?
![Page 18: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/18.jpg)
18
Example: Using on board LEDs
Next steps are:I Configure the GPIOE in output modeI Write a value in order to switch on/off LEDs
![Page 19: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/19.jpg)
19
Example: Using on board LEDs
Configure the GPIOE in output mode:I GPIO port mode register (GPIOx_MODER)
Which value do you have to write? Which address?
![Page 20: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/20.jpg)
20
Example: Using on board LEDs
Write a value in order to switch on/off LEDs:
Which value do you have to write? Which address?
![Page 21: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/21.jpg)
21
Interrupts
Nested vectored interrupt controller (NVIC)I 74 maskable interrupt channelsI 16 programmable priority levels (4 bits of interrupt priority are
used)I Low-latency exception and interrupt handlingI Power management controlI Implementation of System Control Registers
![Page 22: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/22.jpg)
22
Configuring Interrupts
To configure a line as interrupt source, use the followingprocedure:
I Configure the corresponding mask bit in the EXTI_IMRregister.
I Configure the Trigger Selection bits of the Interrupt line(EXTI_RTSR and EXTI_FTSR).
I Set the Interrupt Service Routine.I Clear the pending request.
![Page 23: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/23.jpg)
23
External and internal interrupt/event line mapping
36 interrupt/event lines are available: 8 lines are internal(including the reserved ones); the remaining 28 lines areexternal.The GPIOs are connected to the 16 external interrupt/eventlines in the following manner:
![Page 24: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/24.jpg)
24
External and internal interrupt/event line mapping
![Page 25: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/25.jpg)
25
External and internal interrupt/event line mapping
![Page 26: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/26.jpg)
26
Configuring Interrupts
Configure the corresponding mask bit in the EXTI_IMRregister:
![Page 27: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/27.jpg)
27
Configuring Interrupts
Configure the Trigger Selection bits of the Interrupt line(EXTI_RTSR)
![Page 28: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/28.jpg)
28
Configuring Interrupts
Configure the Trigger Selection bits of the Interrupt line(EXTI_FTSR)
![Page 29: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/29.jpg)
29
Configuring Interrupts
Set the Interrupt Service Routine (Vector Table)
![Page 30: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/30.jpg)
30
Configuring Interrupts
![Page 31: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/31.jpg)
31
Configuring Interrupts
![Page 32: STM32: Peripherals - LIRMM](https://reader036.vdocument.in/reader036/viewer/2022081506/62a3969e68b7360e7544681a/html5/thumbnails/32.jpg)
32
Configuring Interrupts
Clear the pending request.