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

ESP32 D21.toggle(), D21.digitalPulse(rst,0,10) not working #1103

Closed
wilberforce opened this issue Mar 6, 2017 · 17 comments
Closed

ESP32 D21.toggle(), D21.digitalPulse(rst,0,10) not working #1103

wilberforce opened this issue Mar 6, 2017 · 17 comments
Labels
ESP32 This is only a problem on ESP32-based devices

Comments

@wilberforce
Copy link
Member

wilberforce commented Mar 6, 2017

See http://forum.espruino.com/comments/13506090/ raised by @user73896
Connect lead between GND and D21

D21.set(); lights up - D21.reset(); CORRECTION does reset.

digitalPulse possible related, @jumjum123 not sure if the timer code for this has been done?

@wilberforce wilberforce added the ESP32 This is only a problem on ESP32-based devices label Mar 6, 2017
@wilberforce
Copy link
Member Author

wilberforce commented Mar 6, 2017

Also need to check D21.toggle()

This fails.

@wilberforce wilberforce changed the title ESP32 D21.reset(); fails also D21.digitalPulse(rst,0,10) ESP32 D21.toggle(), D21.digitalPulse(rst,0,10) not working Mar 6, 2017
@jumjum123
Copy link
Contributor

Works fine on my board with:

  • D21.set() --> led on
  • D21.reset() --> led off
  • D21.toggle() --> led on
  • D21.toggle() --> led off
    No idea whats going wrong on your board.
    Only to make sure, compiled from ESP32 branch

@wilberforce
Copy link
Member Author

wilberforce commented Mar 6, 2017

set & reset works for me too.

Seems to be issue with:

digitalPulse(D22,0,10);

I see a quick flash.

I believe it's meant to leave the LED lit.

@jumjum123
Copy link
Contributor

Just tested toggle one more time directly after reset without doing any command.

  • --> led is off
    
  • D21.toggle() --> led stays off
  • D21.toggle() --> led on
  • D21.toggle() --> led off
  • D21.toggle() --> led on
    So first toggle only has a problem, if pin is not used before.
    Will check digitalPulse later today

@wilberforce
Copy link
Member Author

I get different output! 1v91.390
Toggle only works after a reset()!

Then won't toggle off.

For the pulse:

https://github.com/espruino/Espruino/blob/master/targets/esp32/jshardware.c#L396
int duration = (int)pulseTime * 1000; //from millisecs to microsecs

https://github.com/espruino/Espruino/blob/master/targets/esp32/jshardwarePulse.c#L92

//pin to be pulsed. value to be pulsed into the pin. duration in milliseconds to hold the pin.
void sendPulse(Pin pin, bool pulsePolarity, int duration){

Could be a factor of 1000 out - comments don't match up.

@jumjum123
Copy link
Contributor

jumjum123 commented Mar 6, 2017

Correct, comments don't match. But thats not the problem.
Looks like duration is not used. There is only one pulse.
So one pulse is working fine.
Have to find a nice way to stop.

Oh, sorry, misunderstanding of duration. I have to check the us / ms now.

@jumjum123
Copy link
Contributor

Tested with digitalPulse(D21,0,[4,5,6,7,8]); --> works fine
next test with digitalPulse(D21,0,[4,50,6,7,8]); --> 2nd pulse (50ms) is only 17 ms long

@jumjum123
Copy link
Contributor

RMT timer has a base frequency of 80Mhz.
This can be divided by 1 ... 255
Duration of pulse is 1... 32768
So longest pulse time would be 104ms, at least in theory.
Some more investigation is needed now from my side.
Actually, a divider of 80 is used in Espruino, therefore we use recalculation to usec

@jumjum123
Copy link
Contributor

Found the reason, why D21.reset() did not work.
Config of rmt connects a pin to rmt directly.
Due to that, GPIO cannot set/reset D21 anymore, its not connect to the pin anymore.
According to espressif we would need a gpio_matrix_out with SIG_GPIO_OUT_IDX
We could do this after each pulse, it would take some CPU time.
Any comments to this ?

@wilberforce
Copy link
Member Author

Can we set the config for RMT only to occur when digitalPulse is used?

I wonder of this is also making Onewire inconsistent?

@jumjum123
Copy link
Contributor

The only way, I know, is to config rmt before pulse and to reset to GPIO after the pulse.
Have to find a way to recognize end of pulse (?)
Or the other way, we could switch to GPIO, whenever we set/reset/toggle a pin.

@wilberforce
Copy link
Member Author

Or the other way, we could switch to GPIO, whenever we set/reset/toggle a pin.

That might the cleanest way

@jumjum123
Copy link
Contributor

Is done in ESP32 branch.
Had to reset to rmt in jshardwarePulse too.
Hopefully, this did not create conflicts somewhere else (SPI or I2C for example).
Same problem could appear, if you PIN.set() for an already for SPI assigned pin

@aifer2007
Copy link

aifer2007 commented Mar 7, 2017 via email

@wilberforce
Copy link
Member Author

@jumjum123

Is this all sorted now - can we close, or does it need a pull request to bring into master?

@wilberforce
Copy link
Member Author

@jumjum123

Can we close this now?

@jumjum123
Copy link
Contributor

Works as expected,
as long as nobody finds something different ;-)

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

No branches or pull requests

3 participants