2023-10-13 03:37 AM
Good Day
I am using Spi with Dma. When using the Hal-function "HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)", I want to receive 1000 times Data , which I can set in the size-area. The Problem is that my Spi-peripheral needs constantly Cs-pin to get set and reset to give out Data, else i receive after one usable data just zeros. My question is following: Is there a way to tell the Spi to set and reset the cs when data gets received, and if so, how, or where can this be configured? I am currently using the function in a for loop to receive my Data with the size set to 1. But this is way to slow. Thanks for Helping.
Solved! Go to Solution.
2023-10-31 03:19 AM
So I could solve the Problem. It is simple as that. I am using the NSSP mode wit 2 cycles in Master Inter Data Idleness
2023-10-13 12:58 PM
The typical way is to handle CS as a GPIO pin, set it low prior to starting the call and set it high in the RxComplete callback. Or if you're using blocking functions, immediately after HAL_SPI_Receive.
Some series like the STM32H7 have the capability to do this natively.
Why do 1000x loops of 1 byte instead of a single call with 1000 bytes?
2023-10-16 01:19 AM
First of all, thank you TDK,
The Problem is that I have to redo the function in a for, or while loop is that my SPI-Peripheral needs for every data to be send a CS high and low, or else the ADC does not get the information for giving out data. Thats why I want to find out if threr is a way to set CS high and low every time a value gets transmitted, when getting 1000 Bytes by calling this function only once.
2023-10-16 01:53 AM - edited 2023-10-16 01:53 AM
still no info, what cpu you use ...
ie on H563 u could use TI mode : (if this is, what you want)
SS = CS output
2023-10-16 07:36 AM
What is the problem with setting CS low before HAL_SPI_Receive and high afterwards? I don't see how being in a loop is relevant here. Surely controlling a CS pin works as well inside of a loop as it does outside.
2023-10-23 06:14 AM
Hi, the Problem is that when I set Cs high and low that only one data is transmitted because the Peripheral is build so. Thats the reason i am asking if there exist a way to configure the stm32h723zg in that way, that if a value gets received the cs gets automatically gets set high and low, so the ADC can give out the next value. If I set the CS low than expect lets say 1000 values and set cs high again, I only get one value and 999 times zeros. So thats why I am using the receive-function in a while loop to receive enough values. So is there a way to set cs automatically while this function is ongoing? Thanks in regards
2023-10-31 03:19 AM
So I could solve the Problem. It is simple as that. I am using the NSSP mode wit 2 cycles in Master Inter Data Idleness