Skip to main content
Associate
July 14, 2025
Solved

Datasize SPI

  • July 14, 2025
  • 1 reply
  • 303 views

Hello,

I’ve configured SPI in CubeMX with DataSize = 12 bits. However, when I use the HAL function HAL_SPI_Transmit, the pData argument seems to require a uint16_t (or at least 16-bit aligned) buffer.

I'm a bit confused about how this works in practice. Since I'm sending a 16-bit word, but only configured 12-bit frames, does the SPI peripheral transmit just the lower 12 bits of each word? Or do I need to pack the 12-bit values differently?

I'm still fairly new to STM32 development, so I appreciate any clarification you can offer!

Best regards,
Kewin

Best answer by Kewin_J

Solved after reviewing the declaration again. I just misunderstood something. :))

 

1 reply

Kewin_JAuthorBest answer
Associate
July 14, 2025

Solved after reviewing the declaration again. I just misunderstood something. :))