ESP32 direct port manipulation

Hello I have a AC fan speed controller I made with an Arduino Nano, the code has to run as quickly as possible so that the sine waves are cut up correctly preferably 10Us or less, to which my nano does it in 8Us with direct port manipulation.

However, when I then used a ESP32 so that one core does everything gfx wise and touch and the second core does the fan control, I had to use digitalWrite because i could not figure out direct port manipulation on the ESP32 and as a result the loop time is 32Us note the core is 10x faster..

So I ask does any one know how to do direct port manipulation using an esp32 to set a given pin HIGH or LOW?

KawasakiZx10r:
I have a AC fan speed controller I made with an Arduino Nano, the code has to run as quickly as possible so that the sine waves are cut up correctly preferably 10Us or less, to which my nano does it in 8Us with direct port manipulation.

Really? As fast as that? Are you sure? On what are you basing that? Seems faster than necessary to me, but I might be wrong.

I'm assuming he's using an triac to control power to the fan if that's the case it should be about 20 millisecs.
ie the pin turns on the triac once a cycle.

Yes i am using a triac and yes it is 50 or 60 hz so 10ms or 8.3ms per half sine wave but then i have to divide that by 100 speeds to that's then 100Us or 83Us per speed % then i need to ensure my loop will hit that number as close as possible so i would prefer 10Us or lower so the overshot is as small as possible.

Anyway, since Arduino has no 'peek definition' i just placed an extra variable in the digitalWrite to get an error and found the source of the ESP32 digitalWrite and then found the port manipulation. Using that did not make much difference in stead it turned out to be the interrupter is slow on the ESP32 so i was funny enough able to get a better response just be using the direct port manipulation to read if the pin state is HIGH and a single bool for a lock in the loop function.

No the less i have answered my question and made some process with my scenario.

No the less I have answered my question and made some process with my scenario.

OK, good! Glad you got it sorted.