Author Topic: STM32F411 ADS7056 and how to make them friends  (Read 449 times)

0 Members and 1 Guest are viewing this topic.

Offline bobAkTopic starter

  • Contributor
  • Posts: 39
  • Country: fr
STM32F411 ADS7056 and how to make them friends
« on: December 19, 2020, 12:33:22 pm »
Hello. For this ADC, the documentation say 18 spi clocks. STM32F411 has 8- and 16-bit data frames. How to do it correctly?
Checked the recive data in two 8-bit packets.
Code: [Select]
          SPI1->DR = 0x00;
  while(!(SPI1->SR & SPI_SR_BSY));
  r1 = SPI1->DR;
  SPI1->DR = 0x00;
  while(!(SPI1->SR & SPI_SR_BSY));
  r2 = SPI1->DR;
Works, returns valid data.

How correct is this? Or are there any problems that I don't notice?

I am a beginner with mcu.
Best regards, Boris.

1134582-0

1134582-1
« Last Edit: December 19, 2020, 12:39:55 pm by bobAk »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8184
  • Country: fi
Re: STM32F411 ADS7056 and how to make them friends
« Reply #1 on: December 19, 2020, 01:02:54 pm »
Beware of ancient and too simplistic MCU SPI peripherals that do not support proper set of arbitrary datagram sizes.

Alternatively, beware of weird SPI slave devices requiring transaction lengths not multiple of 8.

SPI datagram lengths not multiples of 8 are surprisingly common. On MCU side, you would like to see at least 4..16 bit options with 1 bit increments. FIFO mode is a big plus. Working nCS-controlled-by-peripheral is even bigger plus, but STM32 always fails this anyway.

The only way left is to bit-bang, or choose a suitable microcontroller, or choose a suitable ADC (quite frankly, I wouldn't put all the blame to the ST; it's a stupid idea to require 18 clock cycles knowing half of the world's microcontrollers are unable to do it.).

More modern devices in STM32 family support 9-bit datagrams so you can create 18-bit datagram by writing two 9-bit words in succession.

If the slave happens to work with illegal transfer length (16 or 24 bits) by accident, then you are lucky.
 

Offline bobAkTopic starter

  • Contributor
  • Posts: 39
  • Country: fr
Re: STM32F411 ADS7056 and how to make them friends
« Reply #2 on: December 19, 2020, 03:01:36 pm »
Thanks for the answer. So I thought correctly. We'll have to lower the resolution and use the ADS7886SB.
Best regards, Boris.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf