microsoft / pxt-calliope

A Microsoft MakeCode editor for the Calliope Mini board
https://makecode.calliope.cc
Other
39 stars 22 forks source link

Analog set period sets the same frequency on all pins, even if API call specifies pin #272

Closed fabianhugo closed 9 months ago

fabianhugo commented 10 months ago

As in pxt-microbit issue 4950 the PWM frequency set by the "analog set period pin P... to (us) 20000" sets the PWM frequency globally (default is 50Hz). Any follow up on this issue? Can this be fixed?

Amerlander commented 10 months ago

Might be a codal issue, the function is defined here: https://github.com/lancaster-university/codal-nrf52/blob/0643733703b4f8f788af81a996f40d1f1a1527bc/source/NRF52Pin.cpp#L643

fabianhugo commented 10 months ago

The behavior of a program on the base of micro:bit samples v2 is the same. Both pins always have the same analog period. Example code:

    while (1){
    uBit.sleep(3000);
    uBit.io.P0.setAnalogPeriodUs(100);
    uBit.io.P0.setAnalogValue(10);
    uBit.sleep(3000);
    uBit.io.P1.setAnalogPeriodUs(500);
    uBit.io.P1.setAnalogValue(10);
    }
Amerlander commented 9 months ago

The block is defined in pxt-common packages and designed for boards that allow separate PWM frequencys. The CODAL does not support this, so I'll close it here.

If this feature is required, it has to be changed in the CODAL.