You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ESP8266: APA102 bit-bangs at ~1.4 Mbit/s (requested 6 MHz); no native HSPI path #4925
On ESP8266, the APA102 controller bit-bangs at about 1.42 Mbit/s. Its default clock is DATA_RATE_MHZ(6), so it runs about 4.2× slower than requested. The output is correct. Only the rate is wrong. This happens even when the strip is on GPIO13/GPIO14, which are the HSPI MOSI/SCK pins.
Measurements
The measurements were taken on an ESP8266EX at 80 MHz, through the AutoResearch apa102Show(nLeds, 20) RPC (examples/AutoResearch/AutoResearchEsp8266.h). Data is on GPIO13 and the clock is on GPIO14. Each figure is the shortest frame time over 20 frames.
LEDs
Frame time
1
75 µs
8
228 µs
32
771 µs
64
1,489 µs
Each LED adds 22.5 µs. That is 32 bits at about 704 ns per bit, roughly 56 CPU cycles per bit. At 6 MHz, 64 LEDs would take about 0.35 ms on the wire.
Cause
src/platforms/esp/8266/fastled_esp8266.h includes the hardware SPI driver only under #ifdef FASTLED_ALL_PINS_HARDWARE_SPI. Without that define, APA102 goes through src/platforms/shared/spi_bitbang/generic_software_spi.h.
In that path, the delay macros aim for about 13 cycles per bit at 80 MHz. The measured cost is about 56 cycles per bit. That suggests the per-bit GPIO register writes dominate, not the pacing delay. This is inferred and not yet profiled.
The opt-in ESP8266SPIOutput in src/platforms/esp/8266/fastspi_esp8266.h wraps the Arduino <SPI.h> library, not the native SDK and HSPI registers.
Proposed follow-up
When DATA_PIN == 13 && CLOCK_PIN == 14, select a native register-level HSPI output by default. It should write SPI1W0..15 and SPI1CMD directly, with no Arduino SPI.h. Use bit-bang for any other pin pair. Keep the #if choice at the dispatch boundary, as described in agents/docs/cpp-standards.md.
Optionally, speed up the bit-bang loop for non-HSPI pins.
Fix the doc mismatch in src/fl/chipsets/apa102.h. Line 24 says the default is DATA_RATE_MHZ(12), but lines 33 and 302 use DATA_RATE_MHZ(6).
Checked against master. The cause analysis holds: fastled_esp8266.h:8 gates fastspi_esp8266.h on FASTLED_ALL_PINS_HARDWARE_SPI, and that file wraps Arduino <SPI.h>. Two additions:
The opt-in hardware path ignores SPI_SPEED too.ESP8266SPIOutput::select() (fastspi_esp8266.h:88) hard-codes SPISettings(3200000, ...). So FASTLED_ALL_PINS_HARDWARE_SPI still can't reach the default 6 MHz, and any requested rate collapses to 3.2 MHz. The native HSPI output in step 1 should derive its divider from SPI_SPEED.
The doc mismatch in src/fl/chipsets/apa102.h is wider than line 24:
Line 292 (APA102 HD) says 24 MHz; the code (line 302) is DATA_RATE_MHZ(6).
Lines 321 and 343 say 24 MHz; the code (lines 326 and 348) is DATA_RATE_MHZ(12).
Step 3 should fix all four comments, not just line 24.
Activity
zackees commentedon Oct 26, 2026
Checked against
master. The cause analysis holds:fastled_esp8266.h:8gatesfastspi_esp8266.honFASTLED_ALL_PINS_HARDWARE_SPI, and that file wraps Arduino<SPI.h>. Two additions:The opt-in hardware path ignores
SPI_SPEEDtoo.ESP8266SPIOutput::select()(fastspi_esp8266.h:88) hard-codesSPISettings(3200000, ...). SoFASTLED_ALL_PINS_HARDWARE_SPIstill can't reach the default 6 MHz, and any requested rate collapses to 3.2 MHz. The native HSPI output in step 1 should derive its divider fromSPI_SPEED.The doc mismatch in
src/fl/chipsets/apa102.his wider than line 24:DATA_RATE_MHZ(6).DATA_RATE_MHZ(12).Step 3 should fix all four comments, not just line 24.
feat(esp8266): native HSPI ping-pong output for APA102 on GPIO13/14 (#…
fix(esp8266): exact HSPI clock, testable divider, one-bit writes
fix(esp8266): native HSPI output for clocked chipsets (#4925) (#4933)
Merge pull request #4936 from FastLED/feat/esp8266-hspi-onddevice-bench
test(esp8266): on-device HSPI rate, bit-bang and pin-level benches