STM32 SPI3 Not Working.

Usually, before building a device, I implement the basic functionality on a breadboard, and this time was no exception. After the basic functionality was implemented, I started routing the board, and along the way it turned out that it was much easier to route the board using SPI3 rather than SPI2, which was used in the project. Why make things hard for myself, I thought at the time, and routed the board using SPI3.

In the end the board came out double-sided, with 0.3 traces and lots of vias; in short, I was too lazy to fiddle with it, so I decided to order it from some guys I know. I placed the order, and while the board was being made, I decided to update the program, replacing SPI2 with SPI3. I updated it, and it didn't work. First I checked the pin configuration and found no errors; the next step was the clocking of the port and alternate functions, and I found no errors there either. Hmm, strange, everything is configured but it doesn't work; but the question is, what exactly isn't working? I connected an oscilloscope to the SCK pin (PB3): there is a clock, but on the other two pins (MISO – PB4 and MOSI – PB5) there is nothing. From this we can conclude that SPI is working, but the controller (in master mode) isn't sending data to the slave. And so the adventures began, which means it's time to open RM0008 and read. Interestingly, at the very beginning of the description of the SPI modules there is a Warning saying in bold that some SPI3 pins are used by default for jtag debugging, and if you still want to use SPI3, you have to disable jtag, and you can use SWD for debugging.

And here are the pins used for jtag debugging, among them our non-working PB4.
STM32 SPI3 Not Working.

Below is a screenshot of the register that lets you select the debug interface (in this case, disable jtag) and a table explaining which pins are used with each combination.
STM32 SPI3 Not Working.

STM32 SPI3 Not Working.

Since I don't need jtag, I disabled it by adding just one line to the code.

//disable jtag, enable swd
AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_1;

SPI3 worked, and that brings another journey to an end)))