Skip to main content
BuggyCode
Associate
September 11, 2020
Question

Is it possible to remap SPI pins to a different GPIO in an STM32G4 ?

  • September 11, 2020
  • 6 replies
  • 3906 views

I am working on a project using STMCubeMX and an STM32G4 i would like to remap the MISO and MOSI pins, if I were to remap PB4 -> SPI_1_MISO to SPI_1_MOSI and viceversa with PB5 -> SPI_1_MOSI to SPI_1_MISO.

I have a Custom PCB with two STM32G4 communicating over SPI, by mistake I have connected PB4 coming from the master device to PB5 on the slave device , and now I am just wondering if it is possible to remap those two pins, according to the datasheet it does not look promising.

As shown here: PB4 has to be SPI_MISO and PB5 has to be SPI_MOSI.

0693W000003RPO9QAO.png

Does anyone know about a workaround for this ?

Thanks

This topic has been closed for replies.

6 replies

Peter BENSCH
ST Technical Moderator
September 11, 2020

No, unfortunately no chance to exchange the pins internally.

BTW: when looking for a possible solution, it is always a good idea to include the necessary details, in this case e.g. that you are talking about an STM32G431.

Good luck with rewiring the pins externally!

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
BuggyCode
BuggyCodeAuthor
Associate
September 11, 2020

is it feasible to use bitbanging in this particular case instead of having to rewire the pins externally ?

Thank you for your time.

Uwe Bonnes
Chief
September 11, 2020

If speed allows, use bitbanging SPI.

BuggyCode
BuggyCodeAuthor
Associate
September 11, 2020

I think this is going to be my only alternative, since it is not possible to exchange the pins internally, do you know where I could find some examples of bitbanging SPI ?

What do you mean by " if speed allows ?" is it the speed at which the CPU is runnning or the specific GPIOs ?

Thank you for your time.

Uwe Bonnes
Chief
September 11, 2020

Bitbanging either hogs the CPU or is slow. So speed may be an issue.

waclawek.jan
Super User
September 11, 2020

You can use BIDIMODE, although it's quite a PITA... :)

JW