# DRV8316 + STM32G431 design request for comments

**URL:** https://community.simplefoc.com/t/drv8316-stm32g431-design-request-for-comments/5421
**Category:** community projects
**Tags:** mt6701, stm32g431, drv8316, stm32
**Created:** [September 2, 2024, 6:03am UTC](https://community.simplefoc.com/t/drv8316-stm32g431-design-request-for-comments/5421 "2024-09-02T06:03:43Z")
**Posts on this page:** 7
**Page:** 3

<div class="post-metadata">

### Author: ![runger](https://community.simplefoc.com/user_avatar/community.simplefoc.com/runger/32/395_2.png) [@runger](https://community.simplefoc.com/u/runger)
#### Post date: [October 26, 2024, 8:04pm UTC](https://community.simplefoc.com/t/drv8316-stm32g431-design-request-for-comments/5421/41 "2024-10-26T20:04:08Z")

</div>

> [@rambros](#):
>
> I can’t get the [arduino\_simplefoc\_boards](https://github.com/simplefoc/simplefoc_arduino_boards) working. This error shows with both boards, lepton and microspora.  
> The generic board defs compile well, but not the simplefoc defs  
> @runger can you please give some advice, I’m totally lost here.

Dear @rambros - sorry to keep you waiting, I did not manage to get to it until now. I have fixed this error, and updated the simplefoc\_arduino\_boards repository. It seems a new version of stm32duino requires some extra defines, which I have now added.

If you pull these changes and restart the Arduino IDE it should work for the Lepton board. For your board definition I am not sure if GitHub reflects the current state of your development on it, but I sent you a PR with some changes here:

> <https://github.com/rambros3d/simplefoc_arduino_boards/pull/1>
>
> \- added fixes to make Lepton work again
> \- added fixes for G431 MCU in Microspor…a board definition
> 
> current state: variant definition for microspora is missing the SystemClock\_Config function.

> [@rambros](#):
>
> ow I know whats wrong, I left out the **PIN\_** prefix  
> It is supposed to be like this:
> 
> ```auto
> -D PIN_SPI_MOSI=PB5 ; SPI MOSI
> -D PIN_SPI_MISO=PB4 ; SPI MISO
> -D PIN_SPI_SCK=PB3 ; SPI Clock
> -D PIN_SPI_SS=PC4 ; SPI Chip Select (SS)
> -D DRV_CS=PIN_SPI_SS
> 
> ```
> 
> With this I can now use the default SPI. No need to manually define a new SPI class.

this can be added to the variant files, to make it automatic…

> [@rambros](#):
>
> I also didn’t get the current sense to work, I got the error that current sense was not initialized, but not the timer error. I tried different gain settings in 8316.

What’s the exact output you get? Do you have debug output switched on?

For low side current sense you do have to link the driver, but I assume you tried that.

---

<div class="post-metadata">

### Author: ![rambros](https://community.simplefoc.com/user_avatar/community.simplefoc.com/rambros/32/7363_2.png) [@rambros](https://community.simplefoc.com/u/rambros)
#### Post date: [October 30, 2024, 2:18am UTC](https://community.simplefoc.com/t/drv8316-stm32g431-design-request-for-comments/5421/42 "2024-10-30T02:18:57Z")

</div>

Thanks for updating the boards.

> [@runger](#):
>
> For low side current sense you do have to link the driver, but I assume you tried that.

Yup you’re right.  
Since everything else is working fine, I’m sure it is some silly error on my part.

I will look into it by this weekend.

---

<div class="post-metadata">

### Author: ![Daan87423](https://community.simplefoc.com/user_avatar/community.simplefoc.com/daan87423/32/4470_2.png) [@Daan87423](https://community.simplefoc.com/u/Daan87423)
#### Post date: [November 1, 2024, 12:17pm UTC](https://community.simplefoc.com/t/drv8316-stm32g431-design-request-for-comments/5421/43 "2024-11-01T12:17:33Z")

</div>

I’ve swapped to the hardware variant of the DRV8316 and tried current sensing again. During the aligning I keep getting an error for phase B. This is the serial output during start-up:

Current sense init success!  
MOT: Monitor enabled!  
MOT: Init  
MOT: Enable driver.  
MOT: Align sensor.  
MOT: sensor\_direction==CCW  
MOT: PP check: OK!  
MOT: Zero elec. angle: 4.19  
MOT: Align current sense.  
CS: Inv A  
CS: Err align B  
MOT: Align error!  
MOT: Init FOC failed.  
Motor ready.

Not sure what to try for troubleshooting this error. I’m using this config: LowsideCurrentSense current\_sense = LowsideCurrentSense(2700, PA2, PA1, PA0);.

I don’t have a oscilloscope right now to measure the phase currents, that will have to wait till next week.

---

<div class="post-metadata">

### Author: ![fsal](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/f/97f17d/32.png) [@fsal](https://community.simplefoc.com/u/fsal)
#### Post date: [April 25, 2025, 2:37pm UTC](https://community.simplefoc.com/t/drv8316-stm32g431-design-request-for-comments/5421/44 "2025-04-25T14:37:29Z")

</div>

Hey rambos,

Did you manage to get the current sensing / torque control to work? We have similar setup and wondering what is needed to get it working

---

<div class="post-metadata">

### Author: ![Antun\_Skuric](https://community.simplefoc.com/user_avatar/community.simplefoc.com/antun_skuric/32/21_2.png) [@Antun\_Skuric](https://community.simplefoc.com/u/Antun_Skuric)
#### Post date: [October 8, 2025, 8:53am UTC](https://community.simplefoc.com/t/drv8316-stm32g431-design-request-for-comments/5421/45 "2025-10-08T08:53:47Z")

</div>

Hi everyone,

I’ve spent some time playing with Microspora boards and I like it a lot. It did take me some time to get the platformio and torque control running but it does work and I’m very happy how minimal it is at the end. I really think this board could be the goto board for SimpleFOC in the future.

You can find a simple template platformio project here:

> **[GitHub - pollen-robotics/microspora\_simplefoc\_firmware: A template platformIO...](https://github.com/pollen-robotics/microspora_simplefoc_firmware/tree/main?tab=readme-ov-file)**
>
> main

Some photos of my setup:

 ![IMG_20251008_102842](https://community.simplefoc.com/uploads/default/original/2X/4/4811d41467fc1dcf81cd9666ed1d545a14acb4f4.jpeg) ![IMG_20251008_102848](https://community.simplefoc.com/uploads/default/original/2X/0/01091a16431ca420be16834c262ea180f95f7da6.jpeg) ![IMG_20251008_102857](https://community.simplefoc.com/uploads/default/original/2X/7/7b7202db60d8e109b56381192a910f45d770fd29.jpeg)

### position control

### torque control

---

<div class="post-metadata">

### Author: ![jackweics](https://community.simplefoc.com/user_avatar/community.simplefoc.com/jackweics/32/9557_2.png) [@jackweics](https://community.simplefoc.com/u/jackweics)
#### Post date: [January 15, 2026, 2:04pm UTC](https://community.simplefoc.com/t/drv8316-stm32g431-design-request-for-comments/5421/46 "2026-01-15T14:04:44Z")

</div>

I have a question, encode on the top side. bottom toward the motor magnets，the PCB does block the magnetic field?

---

<div class="post-metadata">

### Author: ![pleycothh](https://community.simplefoc.com/user_avatar/community.simplefoc.com/pleycothh/32/9195_2.png) [@pleycothh](https://community.simplefoc.com/u/pleycothh)
#### Post date: [January 24, 2026, 2:08pm UTC](https://community.simplefoc.com/t/drv8316-stm32g431-design-request-for-comments/5421/47 "2026-01-24T14:08:05Z")

</div>

I love the board. Building one as well. Thanks for sharing!

[Previous page](https://community.simplefoc.com/t/drv8316-stm32g431-design-request-for-comments/5421.md?page=2)
