Skip to main content
HDaji.1
Senior
July 31, 2021
Question

SPI Chip Select Signal Spike

  • July 31, 2021
  • 4 replies
  • 1458 views

..

This topic has been closed for replies.

4 replies

HDaji.1
HDaji.1Author
Senior
July 31, 2021

I am using SPI function in Nucleo F411RE.

I use PicoScope to capture SPI signals as showed below:0693W00000D1Ax2QAF.jpg0693W00000D1AxCQAV.jpgThe bottom line is Chip Select (CS). How come there is some random spike when it is supposed be kept low.

My code is showed in the following lines:

void spiWrite() {
	// Write 3 bytes starting at given address
 char spi_buf[6];
 
 // write to register 0x03
 spi_buf[0] = 0x03; // register address
 spi_buf[1] = 0x0A;
 spi_buf[2] = 0x84;
 
	HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET);
 
	HAL_SPI_Transmit(&hspi1, (uint8_t *)spi_buf, 3, 100);
 
	HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET);
	delay_us(5);
}

HAL_SPI_Transmit(&hspi1, (uint8_t *)spi_buf, 3, 100);

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET);

delay_us(5);

}

waclawek.jan
Super User
July 31, 2021

Probably poor grounding/return.

Also you can try to decrease the SCK/MOSI slew rate/GPIO drive (GPIO_OSPEEDR setting).

JW

HDaji.1
HDaji.1Author
Senior
July 31, 2021

I only connect SPI pins to PicoScope pins, I didn't forget to connect GND pin. No slave connection yet.

Where to set GPIO_OSPEEDR setting?

HDaji.1
HDaji.1Author
Senior
July 31, 2021

BTW, I tested a case where spi_transmit is not called. I just toggle the CS pin in fast speed (us gap). There is no spike.

waclawek.jan
Super User
July 31, 2021

> I just toggle the CS pin

I see above more signals to change at the same time. Try toggling more pins at once.

> in fast speed (us gap).

As I've said, the slew rate of the signals edge is what matters here, not pulse length.

> Where to set GPIO_OSPEEDR setting?

I don't know, this is your program. I don't use Cube. Probably where other attributes of given pin are set.

JW