cancel
Showing results for 
Search instead for 
Did you mean: 

SPI with STM32f429

Matt G
Associate II

Hi,

I am using an STM32f429 Discovery board with CubeMX and HAL, and have some problems regarding SPI. I am using an DAC which takes data in 24 bit format, 8 control bits and 16 data. 

  1. I can only select between 8 or 16 bit data, not both. If I try to send 8 bit control data in 16 bit mode I get extra clocks either end depending if LSB or MSB is sent first. I have tried changing between modes via the hspi struct but it won't change after first configuration. 

  1. I am using 3 element 8 bit 2D arrays for to store initial control data & output state data but the order of SPI data transmitted via HAL_SPI_Transmit_DMA(&hspi1,Var,3)

when declared as Var[]={1,2,3} is actually {1 3 2} where 3 is transmitted as 85. 

  1. The last element of the array (except the 2nd since order is messed up) is always transmitted as 85 (01010101) regardless of what I set it to. 

Please can someone advise?

Thanks 

11 REPLIES 11
T J
Lead

if you look carefully at the nSS pin in the datasheet of the DAC you will see is not 8 or 16 bit aligned, but message aligned.

I am not sure HAL can work with that.

Matt G
Associate II

I've managed to fix the last two problems. My only issue now is how to switch between 8 and 16 bit mode on the fly? Could someone please advise?

I'm not sure what you mean about nSS pin won't work - afaik hardware nSS in HAL isn't working anyway - is this what you meant? So I was going to soft toggle it myself.