Skip to main content
Marco Ferdinandi
Associate
January 16, 2018
Question

SPI over USART2 on STM32L052K8?

  • January 16, 2018
  • 2 replies
  • 1397 views
Posted on January 16, 2018 at 12:09

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,

Marco
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    January 16, 2018
    Posted on January 16, 2018 at 17:38

    The pin routing does not describe an SPI use case for PA[1..4]

    http://www.st.com/content/ccc/resource/technical/document/datasheet/dc/d6/6d/24/86/2a/40/d3/DM00108217.pdf/files/DM00108217.pdf/jcr:content/translations/en.DM00108217.pdf

     

    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.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Marco Ferdinandi
    Associate
    January 17, 2018
    Posted on January 17, 2018 at 16:32

    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,

    Marco
    Tesla DeLorean
    Guru
    January 17, 2018
    Posted on January 17, 2018 at 16:58

    No, it isn't that complicated to implement

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    waclawek.jan
    Super User
    January 17, 2018
    Posted on January 17, 2018 at 18:16

    See AN4655.

    JW