Skip to main content
PNare
Associate II
December 12, 2020
Solved

CAN and two UARTs in 20 pin TSSOP STM32F042?

  • December 12, 2020
  • 5 replies
  • 2810 views

Hello, can the pin configuration shown below possible?

We need one bidirectional UART and a CAN along with a UART TX for debugging.

0693W000006FXukQAG.pngQuestions are:

  • It says "Pin pair PA11/12 can be remapped in place of pin pair PA9/10 using the SYSCFG_CFGR1 register" So I would only need PA10 to be remapped to PA12 for CAN TX. Is this possible?
  • Can USART be initialized with only TX pin?
  • Would there be any issue with using CAN RX with BOOT0 pin?

Thanks, Prithvi

This topic has been closed for replies.
Best answer by waclawek.jan

> Also is it possible to not assign the MISO, SCK and CS for SPI and only assign MOSI

Yes, this should be possible.

However, I've experimented, and transmitting using

SPI1->DR = (data << 1) | 0x200;

works correctly only if CPHA = 1, so you may want to be aware of that.

And, as I said above, the choice of baudrates is severely limited, so the receiver has to be flexible to accept possibly nonstandard baudrates.

JW

5 replies

waclawek.jan
Super User
December 12, 2020

> I would only need PA10 to be remapped to PA12 for CAN TX. Is this possible?

No, these pins remap as a pair. See description of SYSCFG_CFGR1.PA11_PA12_RMP bit in RM.

> Can USART be initialized with only TX pin?

Yes. It can be initialized with no pins, actually, if you would want to do that.

> UART TX for debugging.

Emulate it in software, use timer, optionally DMA. You even can use SPI MOSI on PA7 to emulate UART quite comfortably, although the baudrate selection would be limited.

JW

PNare
PNareAuthor
Associate II
December 15, 2020

Thanks JW for the quick answer. Can you please point me to resources to get UART out of SPI MOSI?

waclawek.jan
Super User
December 15, 2020

I don't think you'll find this ready-made.

The idea is to set SPI to 10-bit frames, LSB-first, and modify each transmitted byte by adding start and stop bit.

JW

PNare
PNareAuthor
Associate II
December 15, 2020

OK, that I can do. Also is it possible to not assign the MISO, SCK and CS for SPI and only assign MOSI since there is a shortage of pins?

waclawek.jan
waclawek.janBest answer
Super User
December 15, 2020

> Also is it possible to not assign the MISO, SCK and CS for SPI and only assign MOSI

Yes, this should be possible.

However, I've experimented, and transmitting using

SPI1->DR = (data << 1) | 0x200;

works correctly only if CPHA = 1, so you may want to be aware of that.

And, as I said above, the choice of baudrates is severely limited, so the receiver has to be flexible to accept possibly nonstandard baudrates.

JW