cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Chip Select Signal Spike

HDaji.1
Senior
 
6 REPLIES 6
HDaji.1
Senior

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);

}

Probably poor grounding/return.

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

JW

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
Senior

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.

> 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

You are right. Just now I double-checked my wiring. GND pin is wrongly connected.

Thx