Calling native or compiled code from ESP32 #7496
Unanswered
espruino-discuss3
asked this question in
ESP32
Replies: 1 comment
-
Posted at 2024-10-02 by @gfwilliams As you also posted in GitHub lets talk about this there: espruino/Espruino#2561 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2024-10-01 by Montana
Issue
I'm using the
setWatch
function on my esp32 board. How could one create a 'native' function to be called in the interrupt itself?From the documentation
E.compiledC
is unavailable for the esp32 board (understandably so) and I can't seem to find very much information on how to accomplish this. I've also begun trying to create a library to make some native code available following the guide here, but have had issues compiling.Context
I'm working with a RobotDyn AC Dimmer that I want to be controlled by my esp32 board running Espruino. I have setWatch() function watching the
Z-C
pin from the dimmer board. When the watch fires, I can issue a quick pulse to thePSM
pin on the dimmer board to engage the triac. The triac will then remain engaged until the nextZ-C
firing. Configuring the delay between when theZ-c
pin pulses and when I send myPSM
pulse should allow me to control the brightness. The issue that I'm running into is that the pulse sent to thePSM
pin is too slow, resulting in a poor signal to the dimming board and flickering of attached lights. Here is some example code:Oscilloscope readings
The yellow line is the reading from the
ZC
pin and the blue line is the reading from thePSM
pin being output from the esp32. The yellow line is a constant and the blue line appears to berunning
and somewhat random. The blue line should be perfectly in sync with the yellow line and pulse immediately after the rising edge, but neither of these is happening. Additionally, the 1ms pulse being sent is also not 1ms.Postulated solution
My idea for a solution to this is to have a bit of native code compiled such that I can call if from within the interrupt itself and achieve the required performance to achieve a consistent dimming.
Beta Was this translation helpful? Give feedback.
All reactions