• Was looking for maximum PWM frequency any Espruino board can produce. Looking for up to 1.6..2.0MHz. So far I could produce about 262144Hz (2**18) with PICO. Could not find any reference.

    Any experience with upper limit?

    Any alternative to PWM is welcome... I just need a something that I can code control to sweep from about 0.5 MHz to about 2 MHz... best w/ 50% duty cycle.

  • I think PWM can go at about 1/2 the speed of the peripheral clock. Some PWM outputs are on PCLK1 (1/2 speed) and some are on PCLK2 (1/4 speed) so depending which timer is used for the PWM output you can go twice as fast. You can see which is which listed here: https://github.com/espruino/Espruino/blo­b/master/targets/stm32/jshardware.c#L434­-L510

    You could take a look at http://www.espruino.com/STM32+Peripheral­s and see about peeking/poking the Pico's timer peripheral (specifically the prescaler, autoreload register and counter) and see if you can get it to go faster?

  • Btw, A8 - which I used - got obviously blown by some feedback back into the pin... so I switched to B7.

    I could not (yet) read out of the code which pin uses which timer. The poking around in the timers' guts has to wait a bit. For the timed immediate need I have tuned the coil with capacitor to fall into the range of 32..262KHz. For the higher range I have organized a 'classical' bench RC signal generator covering up to 2MHz.

  • I could not (yet) read out of the code which pin uses which timer.

    Try B7.getInfo() :) It's also the same info you get if you hover the mouse over the PWM markers on https://www.espruino.com/Pico#pinout

    I believe it's the first timer that's listed for the pin that gets used - unfortunately there is no way to explicitly set which one gets used for now.

    Even so, I guess going up to 262kHz is quite good.

    I was considering trying to do some circuit stuff with a Pixl.js actually - I thought it'd be quite good to be able to use it as an oscilloscope for some low speed analog stuff.

  • ...kind of embarrassed... don't know what measuring mistake I did in the first place... because with a do over I get easy to 2MHz and even up to 8MHz... latter just not gradually but with jumps...

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

What is maximum frequency of PWM (w/ 50% duty cycle)?

Posted by Avatar for allObjects @allObjects

Actions