2022-02-06 04:55 AM
Hi Everybody!
I'm trying to prototype a force measure application with SD-card on a P-NUCLEO-WB55 Board and I-NUCLEO-CN0216. I'm using the latest CubeIDE.
The SD Card work perfectly both on SPI 1 and SPI 2(In my project i'm using SPI 2 for the different Speed).
I'm trying to use the SPI 1 for I-NUCLEO-CN0216 adapter board.
After Hardware setup with CubeIDE and adding a code for testing with HAL librarys, that just read out the ADC Mode register, the HAL_SPI_Receive() function returns with HAL_ERROR status and 0x00 for the Register data.
I trying all the SPI mode's etup.
I trying all the 3 different SPI CS pin on the adapterboard.
All the boards power up from Vin pin with 12V.
I attach picture from the SPI 1 Setup and from the added code.
Someone already had similar problem?
Can somebody help me?
Solved! Go to Solution.
2022-02-06 07:58 AM
Your HAL_SPI_Transmit call is nonsense. You need to pass a pointer to the data, not a random pointer to whatever data happens to be at address 0x18.
uint8_t data = 0x18;
HAL_SPI_Transmit(&hspi1, &data, 1, 100);
You don't show what ADC_Register_Read is, but probably a similar issue there.
2022-02-06 06:54 AM
Maybe you need measure your SPI signals on AD with scope.
2022-02-06 07:58 AM
Your HAL_SPI_Transmit call is nonsense. You need to pass a pointer to the data, not a random pointer to whatever data happens to be at address 0x18.
uint8_t data = 0x18;
HAL_SPI_Transmit(&hspi1, &data, 1, 100);
You don't show what ADC_Register_Read is, but probably a similar issue there.
2022-02-06 09:01 AM
Thank you very much, you were right. I'm using wrong variables, ADC_Register_Read was uint8_t *. I changed the code with according to your recommendation and it works fine.