Tracing STM32 firmware with DMA SPI
STM32 SPI peripheral clocking out at maximum baud (22.5 MHz)

Tracing STM32 firmware with DMA SPI

In a previous article, I showed how to trace high speed firmware in real-time by writing to SPI protocol. Even though the STM32F4 CPU runs fast (168 MHz), the peripheral bus runs much slower (90 MHz), so that the maximum baud rate I achieved is ~2.5 MHz. If SPI peripheral is available on the accessible pins, then I can speed up the SPI messaging. On the ST motor eval board x-nucleo-ihm08m1, the pins are freely available, so I found SPI3 pins in the upper right corner of the pinout diagram below.

No alt text provided for this image

The STM32 CubeMX configuration window removes a lot of low level configuration.

No alt text provided for this image

Similarly, STM32 Hal API takes care of the low level detail of writing the contents onto the SPI bus. See my previous article for how the local variable "log" is filled in. The header is 4 bytes, and each argument is 2 bytes, so note the length of the buffer given to the API is the number of words (rather than bytes).

if (HAL_SPI_Transmit_DMA(&hspi3, (uint8_t*)&log, 2 + log.n) != HAL_OK) {
  (void)hspi3.State;
}

The SPI elapsed time is 1.6 μs, but you have to wait a lot longer to actually use the DMA peripheral again; the title picture shows that it takes roughly 5 μs from when you handed off the buffer to HAL.

要查看或添加评论,请登录

Henry C.的更多文章

  • Is the God (told in the BOM) a racist bigot?

    Is the God (told in the BOM) a racist bigot?

    Even though racism is a touchy topic (especially in the currently bitterly divisive political environment), I will…

  • The Father and the Son both say: "It's me"

    The Father and the Son both say: "It's me"

    Last week, I wrote about my struggle to understand the famous phrase I am [that] I AM (Exodus 3:14), and how I was…

  • How to meet your own burning bush

    How to meet your own burning bush

    In the LDS church, you are given a once-in-a-lifetime blessing called the Patriarchal Blessing (when you are…

  • My testimony of the Book of Mormon

    My testimony of the Book of Mormon

    Previously, I gave my testimony of the divine creator of the Universe and Life. But in addition to the 3 key belief…

  • My testimony of a divine creator

    My testimony of a divine creator

    It's been 2 years since I got baptized, after a 6 month study period during the pandemic. I reached out to the LDS…

    2 条评论
  • How to repent like an AI

    How to repent like an AI

    Given the hype around AI, it's possible that more people know about machine learning algorithms than the importance of…

  • Modeling a truck front steering from RC parts

    Modeling a truck front steering from RC parts

    So I have an idea for an autonomous truck. I've been noodling on operational concepts, filed international patent…

  • Seeking Miracles: The Book of Mormon; The Earliest Text

    Seeking Miracles: The Book of Mormon; The Earliest Text

    I just bought a copy of The Book of Mormon, The Earliest Text–even though I have trouble understanding the 16th century…

  • Car path tracking SW considerations

    Car path tracking SW considerations

    I am working on autonomously parking an RC truck. The task involves collision-free path generation and following the…

  • ARUCO markers on 3D object

    ARUCO markers on 3D object

    OpenCV makes it easy to estimate a pose of a 2D ARUCO board using the predefined aruco::GridBoard class. But if I want…

社区洞察

其他会员也浏览了