2021-07-08 04:36 AM
Here is the code:
uint32_t AFE4490Read (uint8_t address){
uint32_t data = 0;
uint8_t buf[3];
HAL_GPIO_WritePin(AFE_STE_GPIO_Port, AFE_STE_Pin, LOW); // enable device
HAL_SPI_Transmit(&hspi2, &address, 1, 1000); // send address to device
HAL_SPI_Receive(&hspi2, buf, 3, 1000); // SPI.transfer (data);
data |= (((uint32_t)buf[0])<<16); // read top 8 bits data
data |= (((uint32_t)buf[1])<<8); // read middle 8 bits data
data |= ((uint32_t)buf[2]); // read bottom 8 bits data
HAL_GPIO_WritePin(AFE_STE_GPIO_Port, AFE_STE_Pin, HIGH); // disable device
return data; // return with 24 bits of read data
}
2021-07-08 04:45 AM
Hello @SLONK.1
For STM32 HAL SPI driers there is no a noticeable difference between L4 and F3 series.
Did you verified the configuration you used for F3 from datasheet ? ( Clock, GPIO Pins, ..)
Regards,
Amira
2021-07-08 06:35 AM
Hello,
Thanks for your response.
Yes I verify It. In fact I just generate it with STMCubeMx software. I generate the code on STM32CubeIDE for programming and debugging.
2021-07-08 07:05 AM
Hello and thanks for sharing these details.
I have some doubts about the clock configuration. You can refer to the provided examples (SPI) within STM32F3Cube package and follow the same clock config.
It can help you!
Regards,
Amira
2021-07-08 08:14 AM
Sir,
I'm using STMCubeMx to configure the clock. STM32F3Cube is a package as I know, How can it help me ? How to follow what you are calling "same clock config".
Regards.
2021-07-08 08:44 AM
Monitoring DR has consequences. If your debugger reads data, it won't be read by your program.
How do you know the data on the line isn't 0? Can you show a scope plot of it?
2021-07-08 09:10 AM
Yes I know but when I monitor the same code on STM32L476VETx, I got data and it works fine. So I don't think it is the reason. You can check on the image the value of DR (not 0) when using it. So I think it is not the problem. For the data on the line, I don't know. May be I should find a scope to plot it; I don'h have a scope.
2021-07-08 09:16 AM
2021-07-08 10:04 AM
I see, I check with multimeter and the mean voltage on SPI_SOMI of the STM32F302CBTx is less than the one on the STM32L476VETx where the code works well. I will try to find a scope to cofirm that.