cancel
Showing results for 
Search instead for 
Did you mean: 

CAN and two UARTs in 20 pin TSSOP STM32F042?

PNare
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions

> 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

View solution in original post

5 REPLIES 5

> 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
Associate III

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

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
Associate III

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?

> 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