Skip to main content
JPhan.1
Associate
June 14, 2021
Solved

The chip-selected pin goes high even set low during SPI transition

  • June 14, 2021
  • 6 replies
  • 2284 views

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, &reg, 1, 1000);

      HAL_SPI_Receive(&hspi2, bufp, 1, 1000);

      HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);

}

 0693W00000Bay6FQAR.png

This topic has been closed for replies.
Best answer by JPhan.1

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

6 replies

TDK
June 14, 2021

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.

"If you feel a post has answered your question, please click ""Accept as Solution""."
JPhan.1
JPhan.1Author
Associate
June 15, 2021

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

TDK
June 15, 2021
Nothing wrong with the code that you've shown. Either you're monitoring the wrong pin, or it's not set up correctly, or something else is controlling it.
"If you feel a post has answered your question, please click ""Accept as Solution""."
waclawek.jan
Super User
June 15, 2021

I don't quite understand the Cube gibberish, but maybe you want to use HAL_SPI_TransmitReceive() instead of those two separate functions.

JW

JPhan.1
JPhan.1AuthorBest answer
Associate
June 15, 2021

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

JPhan.1
JPhan.1Author
Associate
June 15, 2021

0693W00000Bb5OQQAZ.png