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

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 มิ.ย. 2024
  • 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-The-Programmer/S...)
    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 20 วันที่ผ่านมา

    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 ปีที่แล้ว +7

    Great explanation 👍🏼 hope you post more stm32 bare metal programming examples.

    • @z-the-programmer4584
      @z-the-programmer4584  2 ปีที่แล้ว +3

      Already working on the next one. Should be out in the coming weeks.

  • @johnfrancis923
    @johnfrancis923 5 หลายเดือนก่อน

    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!

  • @MoleRat94
    @MoleRat94 ปีที่แล้ว +3

    Very Informative!

  • @MohamedAli-ih3kx
    @MohamedAli-ih3kx ปีที่แล้ว +1

    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 👌

  • @arunraj4608
    @arunraj4608 หลายเดือนก่อน

    Such a useful video and such a nice presentation!! Thankyou so much... hats off to the efforts taken for making this video

  • @LeftoverRice99
    @LeftoverRice99 ปีที่แล้ว

    Good explanation! Thanks you

  • @sudharanilashkare2361
    @sudharanilashkare2361 6 หลายเดือนก่อน

    My spi driver search is finally successfull now, Thankyou so much Z- The-Programmer

  • @wilgaced
    @wilgaced ปีที่แล้ว +1

    Great, good work!

  • @jeremywolfe9378
    @jeremywolfe9378 ปีที่แล้ว +8

    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

  • @chemtechleague4128
    @chemtechleague4128 2 ปีที่แล้ว +2

    Amazing!! keep it up

  • @anilsuha5301
    @anilsuha5301 2 ปีที่แล้ว

    Superb 👌keep continuing

  • @imk8729
    @imk8729 ปีที่แล้ว +1

    Thanks for your nice tutorial 👍

  • @intjengineering
    @intjengineering 2 ปีที่แล้ว

    Thank you very much!!!

  • @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 ปีที่แล้ว

    Hello, this is a great example. Can you please correct the github link. It shows 404 error.

  • @lohikarhu734
    @lohikarhu734 20 วันที่ผ่านมา

    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.

  • @mahmoodraeisi9803
    @mahmoodraeisi9803 2 ปีที่แล้ว

    Hello, how can I contact you?

    • @z-the-programmer4584
      @z-the-programmer4584  2 ปีที่แล้ว +1

      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