Skip to main content
EE_CV
Associate
February 4, 2019
Question

USART in SPI mode

  • February 4, 2019
  • 4 replies
  • 4725 views

Is it possible to configure the USART as SPI master, with SPI slave having 16 bit data frames (AD5592R) ?

This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
February 4, 2019

I don't see that working

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
EE_CV
EE_CVAuthor
Associate
February 4, 2019

Is that because the USART in SPI mode only support 8-bit data?

Tesla DeLorean
Guru
February 4, 2019

Well arguably it can deal with 9 bits and some stop/start configurations, but I don't see a winning move here in terms of generating usable signalling. I'm lacking scope/context.

Why can't you use an SPI peripheral? Which STM32 part are we talking about?

Are you trying to send data, receive, or combination of both? At what speed?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
February 4, 2019

If one SPI is used as master and you need another one, you could use alternate GPIOs and dynamically (and time multiplex) its use. Otherwise, was told USART can be a slower speed version of SPI Master with CK output pin. SPI by SW emulation using GPIOs in push-pull mode (if 4 wires configuration) can give you few MHz frequency raw.

EE_CV
EE_CVAuthor
Associate
February 4, 2019

Yeah we will probably try GPIOs in push-pull mode and see how that works out. Without a timer connected to the USART clock it's not clear to me if there is any advantage configuring the USART peripheral at all. 1MHz raw is fine for us as long as it doesn't tie up the CPU for too long, which remains to be checked. At the very fastest we need to communicate with the SPI slave every 3ms.

waclawek.jan
Super User
February 4, 2019

Isn't 16 bit = 2 x 8 bits?

What's the issue? I presume you are talking about the synchronous mode of USART. Is the peripheral in question picky about clocks being continuous?

https://community.st.com/s/feed/0D50X00009bLS7GSAW

JW

EE_CV
EE_CVAuthor
Associate
February 4, 2019

Yes I am looking at synchronous USART used as SPI master. Would the USART insert a stop and start bit between each 8 bits in that mode? If so wouldn't that mess up the slave?

waclawek.jan
Super User
February 4, 2019

> Would the USART insert a stop and start bit between each 8 bits in that mode?

Internally it times the stop/start bit, but won't issue clocks for them, so this demonstrates itself as a gap in the clock, as I wrote in the post I linked above.

> If so wouldn't that mess up the slave?

No, except if the slave requires continuous (strictly regular) clock.

JW