SPI driver - configured 2 MHz, but 1 Mhz on the wire

NikolaiBaschinski
Posts: 9
Joined: Mon Apr 27, 2026 8:37 pm
Location: Hannover, Germany

SPI driver - configured 2 MHz, but 1 Mhz on the wire

Postby NikolaiBaschinski » Fri May 08, 2026 3:42 pm

Hi guys!

I have configured my SPI driver with 2 MHz clock. But on the wire I see just 1 MHz. Why?

Code: Select all

  spi_device_interface_config_t devcfg_bme = {
    .clock_speed_hz = 2 * 1000 * 1000,
    .mode = 0,
    .spics_io_num = GPIO_NUM_5, // CS Pin
    .queue_size = 1,
    .flags = 0,
    .command_bits = 0,
    .address_bits = 0,
    .dummy_bits = 0
  };
Attachments
bmp_149_000.png
bmp_149_000.png (14.15 KiB) Viewed 66 times

Sprite
Espressif staff
Espressif staff
Posts: 10612
Joined: Thu Nov 26, 2015 4:08 am

Re: SPI driver - configured 2 MHz, but 1 Mhz on the wire

Postby Sprite » Sat May 09, 2026 5:19 am

Because you're looking at the data. The definition of SPI is that with each cycle (up-down) of the clock signal, there will be one bit of data on the data output. You're measuring two bits of data here (one high, one low), so the corresponding clock had two cycles (high-low-high-low) and would be the 2MHz you expect. Measure SCLK directly if you're in doubt.

NikolaiBaschinski
Posts: 9
Joined: Mon Apr 27, 2026 8:37 pm
Location: Hannover, Germany

Re: SPI driver - configured 2 MHz, but 1 Mhz on the wire

Postby NikolaiBaschinski » Mon May 18, 2026 6:03 pm

You're right! Thank you! :roll:

Who is online

Users browsing this forum: akashgaur0001 and 6 guests