2020-12-12 05:55 AM
Hello, can the pin configuration shown below possible?
We need one bidirectional UART and a CAN along with a UART TX for debugging.
Questions are:
Thanks, Prithvi
Solved! Go to Solution.
2020-12-15 06:01 AM
> 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
2020-12-12 01:28 PM
> 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
2020-12-14 10:43 PM
Thanks JW for the quick answer. Can you please point me to resources to get UART out of SPI MOSI?
2020-12-15 12:39 AM
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
2020-12-15 04:33 AM
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?
2020-12-15 06:01 AM
> 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