No video

How To Write An STM32 SPI Driver (Full-Duplex Master Mode)

  Рет қаралды 31,631

Z-The-Programmer

Z-The-Programmer

Күн бұрын

This tutorial demonstrates how to write a full-duplex SPI driver for an STM32 microcontroller without any hardware abstraction layers (bare metal) to communicate over the Serial Peripheral Interface (SPI) with other SPI devices with the microcontroller being the master on the bus. The tutorial covers the necessary SPI theory, STM32 SPI registers required and includes a coded example developed throughout the tutorial. After the code is fully developed, the SPI driver is tested by getting the microcontroller to communicate with the MPU9250 and reading data from its registers.
The microcontroller used is the STM32L432KC but the registers, programming, and configuration are the same (or similar) across the stm32 boards. The tutorial covers the MPU9250 IMU to provide context for configuration choices of the SPI peripheral in the microcontroller.
Source code for this tutorial is available at:
github.com/Z-T...)
Timestamps:
00:00 - Introduction
00:31 - SPI Theory
02:57 - Picking SPI Pins
03:13 - Peripheral Clocks
04:06 - SPI Pin Configuration
05:35 - SPI Peripheral Configuration: Control Register 1
12:19 - SPI Peripheral Configuration: Control Register 1 Code
13:01 - SPI Peripheral Configuration: Control Register 2
15:58 - SPI Peripheral Configuration: Control Register 2 Code
17:08 - SPI Transfer Function
23:09 - SPI Communication Test
24:23 - SPI Reconfiguration (V2)
27:04 - SPI Communication Test (V2)
27:22 - End

Пікірлер: 26
@lohikarhu734
@lohikarhu734 3 ай бұрын
Thanks for showing monitor screen big enough to see on my tablet, since I'm stuck in a hospital bed...
@aishaal-noori9496
@aishaal-noori9496 2 жыл бұрын
Great explanation 👍🏼 hope you post more stm32 bare metal programming examples.
@z-the-programmer4584
@z-the-programmer4584 2 жыл бұрын
Already working on the next one. Should be out in the coming weeks.
@johnfrancis923
@johnfrancis923 8 ай бұрын
Absolutely fantastic! I've scoured countless resources in search of a comprehensive guide on configuring and initializing hardware from scratch, steering clear of manufacturer libraries. Your content is a gem-thank you for simplifying what seemed like a daunting task!
@sudharanilashkare2361
@sudharanilashkare2361 8 ай бұрын
My spi driver search is finally successfull now, Thankyou so much Z- The-Programmer
@MohamedAli-ih3kx
@MohamedAli-ih3kx Жыл бұрын
Such an insightful video, i hope u keep making more videos about writing device drivers for Microcontrollers like STM32 for different peripherals such as UART DMA I2C I2S ADC, i really hope that man, keep up the good work 👌
@jeremywolfe9378
@jeremywolfe9378 2 жыл бұрын
Great video! One recommendation is that it is best practice to use the CMSIS library and all the defines that come with it. It is almost impossible for someone to tell what (0x1
@z-the-programmer4584
@z-the-programmer4584 2 жыл бұрын
That's a good point. Thank you for advice!
@arunraj4608
@arunraj4608 4 ай бұрын
Such a useful video and such a nice presentation!! Thankyou so much... hats off to the efforts taken for making this video
@MoleRat94
@MoleRat94 2 жыл бұрын
Very Informative!
@imk8729
@imk8729 2 жыл бұрын
Thanks for your nice tutorial 👍
@z-the-programmer4584
@z-the-programmer4584 2 жыл бұрын
You're welcome. More coming soon :)
@wilgaced
@wilgaced 2 жыл бұрын
Great, good work!
@chemtechleague4128
@chemtechleague4128 2 жыл бұрын
Amazing!! keep it up
@anilsuha5301
@anilsuha5301 2 жыл бұрын
Superb 👌keep continuing
@LeftoverRice99
@LeftoverRice99 2 жыл бұрын
Good explanation! Thanks you
@intjengineering
@intjengineering 2 жыл бұрын
Thank you very much!!!
@lohikarhu734
@lohikarhu734 3 ай бұрын
Your typing is a bit too fast for me to follow, but, that's why they pay you the big bucks. It's a good thing that this controller is not too complex! Actually, it's a good example of the "double-edged sword" oh having incredible flexibility in a small device, but requiring quite a bit of internal configuration to get through the flexible pathways... I started with XC6801, 1978, which was a kind of beginning of the trend, with 2 or 3 functions on port pins, and a few registers to get the desired results.
@Wuetr
@Wuetr 2 жыл бұрын
lovely!
@rick_er2481
@rick_er2481 2 жыл бұрын
Thank you (Y)
@manojsuryawanshi1334
@manojsuryawanshi1334 Жыл бұрын
i am not able to read more than 256 bytes in externnal spi
@pedrovaaz7942
@pedrovaaz7942 2 жыл бұрын
Hello, this is a great example. Can you please correct the github link. It shows 404 error.
@z-the-programmer4584
@z-the-programmer4584 Жыл бұрын
Hi, sorry about that. The link should work now.
@mahmoodraeisi9803
@mahmoodraeisi9803 2 жыл бұрын
Hello, how can I contact you?
@z-the-programmer4584
@z-the-programmer4584 2 жыл бұрын
Hey, what problem are you having? :) If the question is not too complex maybe I can answer here, otherwise you could give me your email or something and I can message you?
@mahmoodraeisi9803
@mahmoodraeisi9803 2 жыл бұрын
hormozbazar(Atsine)Gmail
SPI: The serial peripheral interface
33:00
Ben Eater
Рет қаралды 676 М.
STM32 SPI Interrupt Tutorial: Setup And Usage With Registers
19:07
Z-The-Programmer
Рет қаралды 7 М.
Бутылка Air Up обмани мозг вкусом
01:00
Костя Павлов
Рет қаралды 1,6 МЛН
How I Did The SELF BENDING Spoon 😱🥄 #shorts
00:19
Wian
Рет қаралды 35 МЛН
IQ Level: 10000
00:10
Younes Zarou
Рет қаралды 13 МЛН
Challenge matching picture with Alfredo Larin family! 😁
00:21
BigSchool
Рет қаралды 31 МЛН
I2C and SPI on a PCB Explained!
15:34
Altium Academy
Рет қаралды 144 М.
Understanding SPI
11:50
Rohde Schwarz
Рет қаралды 80 М.
#8. SPI in STM32 using Registers  || Tx and Rx  || Full-duplex mode
32:19
STM32 UART: Register Configuration, Transmission and Reception
19:36
Z-The-Programmer
Рет қаралды 4,7 М.
Top 10 Emerging Technologies of 2024 (According to Science)
10:45
AI Uncovered
Рет қаралды 20 М.
Can We Create New Elements Beyond the Periodic Table?
18:07
PBS Space Time
Рет қаралды 299 М.
Бутылка Air Up обмани мозг вкусом
01:00
Костя Павлов
Рет қаралды 1,6 МЛН