0
\$\begingroup\$

I have a ESP8266-01 and a Microchip 23LC1024 memory chip which communicates via SPI bus, and I want to drive it using the ESP8266-01. My thought is to implement the SPI protocol in software i.e. bit-banging. My concern is about driving the clock signal in very specific timings. Basically this question is a generic question about SPI: If SPI is a synchronous protocol, which means that the clock of the master tells the slave when to read/write data, does the clock frequency must be very specific? I mean - does the clock must go HIGH and LOW in a very rigid time intervals?

\$\endgroup\$
1
  • \$\begingroup\$ use an esp8266 module with hardware SPI pins accessible \$\endgroup\$
    – Juraj
    Jul 24, 2021 at 5:24

1 Answer 1

2
\$\begingroup\$

The clock frequency is irrelevant, as long as it's low enough.

The datasheet says the maximum frequency is 20 MHz, so that limits the highest speed. That equals to 50ns clock period.

The other requirement for the clock is that it must be high for at least 25ns and low for at least 25ns, which totals up to 50ns.

The third requirement for the clock is that it must transition fast enough, it must go from low to high, and from high to low, in 20ns.

There is no requirement for minimum clock frequency or maximum value for the clock to be high or low. You can transmit bits how irregularly you want, and even take infinitely long time periods between bits.

\$\endgroup\$
5
  • \$\begingroup\$ Doesn't the requirement that it must be high for 25ns and low for 25ns is actually a requirement for a maximum frequency? What's the difference between them? \$\endgroup\$
    – YoavKlein
    Jul 23, 2021 at 12:34
  • \$\begingroup\$ OK, I'll add a word to clarify that. Better? \$\endgroup\$
    – Justme
    Jul 23, 2021 at 12:35
  • \$\begingroup\$ ok so basically the second one contains the first one. Thanks! So if the ESP8266 runs 160Mhz I need to make sure to add delays in my code between the instructions to pull the clock HIGH and LOW? \$\endgroup\$
    – YoavKlein
    Jul 23, 2021 at 12:39
  • \$\begingroup\$ Yes, correct, most likely toggling clock high and low will result in too fast clock. There are many ways to make delays. But I would have thought ESP32 devices have hardware SPI, are you sure it does not have hardware SPI interface? Is ESP8266-01 somehow special so it does not have SPI? \$\endgroup\$
    – Justme
    Jul 23, 2021 at 12:45
  • \$\begingroup\$ The ESP8266-01 doesn't break out the SPI pins, only 4 GPIOs. I'm doing it mostly for educational purposes. \$\endgroup\$
    – YoavKlein
    Jul 23, 2021 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.