cancel
Showing results for 
Search instead for 
Did you mean: 

Hi All, I need to transfer 24 bit of data through STM 32 SPI , the challenge is that the IP only allow to transfer 8 or 16 bit of data .

RSree.1
Associate II

Things that have tried.

  1. Used the GPIO as chip select . In this configuration , the width of chip selected pulse is more than expected. ( Attached oscilloscope short for your reference ).

Kindly requesting to sent the procedure or sample code to sent 24 bit of data through STM32 SPI

14 REPLIES 14

TDK,

while I agree with everything you wrote, but, even if clock is 16MHz and Cube/HAL is used, isn't cca 10us for pulse generated by two consecutive HAL_GPIO_WritePin() calls too much? That's like 160 clock cycles...

This is 'F7, can AXI be the reason? I don't use 'F7...

[EDIT]

From the bus structure it appears that in 'F7 GPIO (and both AHB buses going to peripherals) don't go through the AXI attachment, but directly through AHBP. Pity the RM does not deal with this in details...

But then the "slowness" is a mystery to me...

[/EDIT]

JW

The hardware NSS of SPI in master mode is mostly useless.

One way to make SPI timing more deterministic and avoid "manual" wiggling of NSS is to generate the clock signals using cascaded timers, and connect them externally to SPI set as a slave. Not trivial.

JW

> even if clock is 16MHz and Cube/HAL is used, isn't cca 10us for pulse generated by two consecutive HAL_GPIO_WritePin() calls too much?

Yes, seems like too much. I can't really explain that either, but could be the OP simplifying code. I don't use F7 either.

> HAL_SPI_Transmit(&hspi1,(uint8_t *) &EEPROM_WRDI , 1, 100);

Actually, since the word size is limited to 16 bits, I don't see how the exact code presented (which sends 1 word) could have produced the scope screenshot (which shows 24 bits). Could be missing something.

If you feel a post has answered your question, please click "Accept as Solution".
RSree.1
Associate II

Hi All,

I tried the advice from TDK ,

  1. changing the clock frequency of AHB Bus (GPIO) and APB2 ( attached the screen for the clock setting).
  2. Increased the level of optimization of the tool, but this does not helped me to reduce the timing.

With clock frequency change ,got significant improvement on the timing. ( Oscilloscope screen shot attached) .

If you have any more suggestion to improve the timing , kindly advice me.

Regards,

Rahul S

RSree.1
Associate II

Oscilloscope screen shot