Problem with analogWrite() on more than one pin

Posted on
  • Hi at all,

    first of all thank you so much for this project (of cause I am a kickstarter baker).

    Because I could not wait I ordered a olimexino-stm32 board and espruino worked like a charm.


    I am unable to get PWM working on two pins simultaneously.

    // This works:
    analogWrite(D37, 0.02, {freq:1000});
    // This does not work:
    analogWrite(D37, 0.02, {freq:1000});
    analogWrite(D4, 0.02, {freq:1000});
    // --> D4 keeps LOW

    I am pretty sure this is a mistake on my part.

    Many thanks and sorry for my english :-)


    After two hours I found out, that it works with another pin combination, e.g. D37 and D36.
    Probably it does not work with pins with ADC functionality?!

  • Hi Graham, you may just be unlucky... The STM32 has a bunch of timers, but not enough for each pin - so sometimes if you set one pin and it uses a timer that was in use by another, it gets reset.

    I guess this is something that we could warn about with a little work...

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Problem with analogWrite() on more than one pin

Posted by Avatar for Graham @Graham