Hi All
I’ve been working on a custom SimpleFOC project to build a small desk toy. I’ve gotten everything running using some off the shelf parts and I have ordered a custom board with everything I need. Unfortunately I’ve been having a tough time debugging the new board. The board uses an STM32F103CBT6, DRV8311, and an AS5600 (I2C). I have been using Arduino IDE to upload code and have been successful in running open loop code. However I think there may be an issue with the I2C communication to the AS5600. I am having difficulties working through the issue as my board does not feature a usb plug/communication. I was not able to find very comprehensive documentation for utilizing the Arduino IDE debug for this case. My questions for you; Thanks in advance.
#1 Whats the best way to debug using the SWCLK and SWDIO pins in Arduino IDE? I’d like to be able to read the serial terminal if possible.
#2 Should I just switch over to using the STM Cube IDE instead of Arduino IDE?
#3 If(#2 == true) How do I get SimpleFOC into STM cube IDE?
You need UART RX and TX pins for Arduino serial monitor, and an FTDI adapter to connect to USB on the computer. Also be aware that you have to hunt down a driver for the FTDI. It took me a day of struggle to figure that out when I first used one and assumed Arduino IDE would have installed it for me.
I only use SWCLK and SWDIO for programming via STM32CubeProgrammer with a cheapo ST-Link v2 mini. Presumably you can do some kind of debugging with them, but I’ve never looked into it.
If you don’t want to redesign your board to make UART accessible, you can solder fine wires directly to the pins on the chip. Then hot glue the wires to the board to protect the delicate solder joints from fatigue (hot glue can be removed with alcohol later if necessary).
Darn. Looks like I jumped the gun on ordering new boards. In that case I’ll probably buy a similar “Blue pill” style board to work out the issues. Thanks.
For using the UART no external components are needed. So with a little soldering skill you can solder some thin wires to the UART pins of your MCU and connect a serial to USB adapter for debugging.
In the same way you can also use the SWO line on the STLink. That’s only a single extra line in addition to the SWD pins. I can show you how t reroute the serial output via SWO.
If you don’t think you can solder to the MCU pins, you could also order some probes like PCBBite: https://sensepeek.com/2x-sp10-probes-for-dmm-redblack
With those you can connect to the MCU pins reliably without soldering.
Oh, another even easier to try idea:
Try to use MCUViewer: GitHub - klonyyy/MCUViewer: Real-time embedded variable & trace viewer
The variable viewer should work just using your existing SWD lines. You can create some extra global variables which you just use for debug output…
This one looks really good. I’ll have to try this one. Thanks.
You need UART RX and TX pins for Arduino serial monitor, and an FTDI adapter to connect to USB on the computer. Also be aware that you have to hunt down a driver for the FTDI.
@dekutree64 I don’t suppose you have a good tutorial that I can follow on this? I’ve been struggling to find a resource that uses Arduino IDE. I got the FTDI adapter and got the drivers from the FTDI website. I’m having trouble with the Arduino code. Can I just use the regular serial.print() in the code I upload to the STM32? I’ve got the TX on the STM32 hooked to the RX on the FTDI chip and vice-versa. Do I need to do anything else connection wise between the two? I appreciate the help.
Yeah, it’s just the regular serial functions. You also need to connect ground to the FTDI, and tell it which pins you’re using since most STM32 chips have multiple UART interfaces. Mine looks like this:
Serial.setTx(PC10);
Serial.setRx(PC11);
Serial.begin(115200);
@dekutree64 The setTx and setRx are exactly what I was missing. Thanks.
The best way by far to solve this problem for everyone forever is to collaborate on one good board that is reasonably broadly applicable. It doesn’t have to suit everyone, you can make forks. The foundation will really help a lot. The price goes down, quality goes up, bugs get squashed.