pin.configure(PWM_OUT_STEPS, period, dutyCycle, stepCount)

Hi All,

So I’ve been using this line of code in my program: hardware.pin8.configure(PWM_OUT_STEPS, period, 0.5, 10);

My hope is that the led associated with the pin will blink “stepCount” number of times with the “period” variable.

i.e. If I put in 10 for stepCount, I want the led to blink 10 times with the period it’s given.

Am I misunderstanding the function of stepCount?

Currently when I put in a number, the led blinks forever with that period and ignores the stepCount.

The exception being that if I use “1” as my StepCount, the LED just stays on.

Any help is much appreciated
Thanks!

You are misunderstanding what PWM_OUT_STEPS is used for.

PWM_OUT_STEPS is meant to be used when you need to specify exact duty cycle, but not frequency. For example, if you have an IC which needs exactly 0.125 duty cycle PWM you would would specify a step count of 8 and a period of 0.125. This would yield an unknown frequency, but an exact duty cycle. If you used the default PWM_OUT the OS may decide to divide your frequency into 100 steps so when you specify 0.125 it would be rounded to 0.12 or 0.13.

You will need to write code which blinks your LED the specified number of times. We don’t have a support library for this, but here is some code I wrote a while back which does this, but is pretty hard to understand:

Thanks!