2018-01-16 03:09 AM
Hi,
I would like to know how to use the USART2 on my board (integrating the STM32L052k8 mcu) to communicate in SPI with an external slave.Is it possible? How can I do it? Is there an example or a snippet which I can use as starting point?
Finally: my first target is to build a transparent bridge USB - SPI (over the pins PA1 PA2 PA3 PA4). Is there an example or a guideline which I can follow?Thanks in advance,Marco2018-01-16 08:38 AM
The pin routing does not describe an SPI use case for PA[1..4]
You will need to bit-bang those GPIO pins.
There might be some way to use the USART in a synchronous mode, but you'll need to be able to address the start and stop bits, etc. I would suggest hooking to a logic analyzer and reviewing the signalling you can generate.
2018-01-17 08:32 AM
Hi,
thanks for the answer. At this point, is there a software library which implements SPI in software using pins as GPIO for my STM32L052k8 mcu?Thanks in advance,Marco2018-01-17 08:58 AM
No, it isn't that complicated to implement
2018-01-17 09:16 AM
See AN4655.
JW
2018-01-17 09:38 AM
Configure required GPIO pins (INPUT, OUTPUT) then try to mimic the SPI timing. For each bit you want to send out you need to set the value of the output being MOSI and change the clock pin to make the other side clock-in the bit.