Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is shiftOut on ESP32 so much slower than on original Espruino boads? #1915

Open
MaBecker opened this issue Aug 17, 2020 · 9 comments
Open
Labels
enhancement ESP32 This is only a problem on ESP32-based devices

Comments

@MaBecker
Copy link
Contributor

Those STM32 boards are so much faster when it comes to GPIO's than the ESP32 - amazing.

So why is the ESP32 with 240 MHz and a dual core so much slower?

@MaBecker MaBecker added enhancement ESP32 This is only a problem on ESP32-based devices labels Aug 17, 2020
@MaBecker MaBecker changed the title Why is any GPIO task on ESP32 so much slower than on original Espruino boads? Why is shiftOut on ESP32 so much slower than on original Espruino boads? Aug 18, 2020
@MaBecker
Copy link
Contributor Author

shiftOut differences:

  • Added pin info for bit-banded pin addresses (and jshGetPinAddress) - only for STM32s

  • jshIsPinValid - not for STM32s

so there is potential for optimisation.

@jumjum123
Copy link
Contributor

Compare simple functions like:
var a= 0; for(var i = 0; i < 100000;i++) a++;
Is cpu the problem, or compiler, or RTOS, or ???

@gfwilliams
Copy link
Member

I think in the JS execution case it's probably that while the CPU is fast it's having to grab the code to execute out of QSPI flash on demand? I imagine if you found the 'hot' interpreter functions and loaded them into RAM then execution speed would raise dramatically

@MaBecker
Copy link
Contributor Author

I imagine if you found the 'hot' interpreter functions and loaded them into RAM then execution speed would raise dramatically

Yes, with ESP32 i2s parallel dma you can have about 500fps for a 64x64 panel without any flicker.

@MaBecker
Copy link
Contributor Author

MaBecker commented Aug 19, 2020

Reading the esp32 technical reference manual state that pins are register mapped

input

  • one regsiter for D0-D31 and one for D32-D39

output

  • one register to set D0-D31 and one for D32-D39 high
  • one register to set D0-D31 and one for D32-D39 low

So the shiftOut for ESP32 will never be as fast as on STM32 boards

But ESP32 offers i2s, which can do parallel shiftout with dma, whith nearly no cpu impact.

Just added a sample video to this conversation

@gfwilliams
Copy link
Member

It's possible that jshGetPinAddress could be extended to be an address + bitmask. That would benefit nRF52 greatly as well

@MaBecker
Copy link
Contributor Author

The ESP32 has a limit of 4MHz for setting gpio's via register. Just throttled i2s from 40MHz to 3MHz and the result is still ok.

It's possible that jshGetPinAddress could be extended to be an address + bitmask. That would benefit nRF52 greatly as well

Great! So working on this is a win for supported boards a well.

For the ESP32 there is one register plus bitmap to set a pin and a different register plus bitmap to set a pin low.

@MaBecker
Copy link
Contributor Author

@jumjum123 can you please share your code for this.

@jumjum123
Copy link
Contributor

jumjum123 commented Apr 25, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ESP32 This is only a problem on ESP32-based devices
Projects
None yet
Development

No branches or pull requests

3 participants