2021-06-14 04:01 PM
Hello Group,
I am reading SPI from the Nucleo STM#@F401RE with the ST accelerometer LIS2DW12. I set the chip-selected pin low during the transition, but I saw the selected pin go high.
How I fix this problem?
Thanks a lot for your time,
Jack
void readId()
{
uint8_t bufp[1];
uint8_t reg = LIS2DW12_WHO_AM_I;
reg |= 0x80;
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi2, ®, 1, 1000);
HAL_SPI_Receive(&hspi2, bufp, 1, 1000);
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
}
Solved! Go to Solution.
2021-06-15 02:36 PM
Hello Group,
I found my problem.
My logic analyzer ground connection is loose and that causes this problem.
I put here the correct result.
Thanks,
Jack
2021-06-14 04:56 PM
Is CS_up configured as a GPIO output pin?
Break it down to where you can toggle the pin successfully, then add in the SPI transfer.
2021-06-14 05:12 PM
Yes, set the chip-selected pin as GPIO output and control it.
During the transition, I set it low, but I see a glitch that goes high. So what is the problem causes this.
Thanks,
Jack
2021-06-14 05:17 PM
2021-06-14 11:39 PM
I don't quite understand the Cube gibberish, but maybe you want to use HAL_SPI_TransmitReceive() instead of those two separate functions.
JW
2021-06-15 02:36 PM
Hello Group,
I found my problem.
My logic analyzer ground connection is loose and that causes this problem.
I put here the correct result.
Thanks,
Jack
2021-06-15 02:37 PM