Have you studied the code in pwm_tones in the current SDK 2.0.1?
We have also posted sample code here:
Several PWM posts are on the community - Search using PWM.
Let me know if this answers your questions.
yes, I browsed thru all the sample code and searched in the discussions but without any luck.
I know how to configure PWM but I don't know if I can get the current state of the PWM signal of lets say PWM0 which gets routed to P26.
I need to sync an action in my firmware with the falling edge of the PWM signal once. To do this I need a way to check if P26 is 0 or 1.
I think I can use gpio_getPinInput(GPIO_PIN_26/16, GPIO_PIN_26%16) to retrieve the state of P26 but I am not sure if gpio_getPinInput() would return the current state if P26 is configured for PWM.
One solution would be to connect another GPIO to P26 and use this GPIO as an input but I want to avoid losing a valuable GPIO for this.
Another solution would be to use a PWM which is dual-bonded with another GPIO (like PWM2 which is available on P14 and is dual-bonded to P38) but this would mean changing the pin assignments on our hardware.
gpio_getPinInput() will not return the current output level of the GPIO when the output is being driven by PWM. You have to use another GPIO or one of the bonded pins.
Funny thing is: I tried it out today on a BCM92073X_LE_KIT and it *does* work.
I configured PWM0 @ GPIO P26 to output a 5kHz PWM signal with 50% duty cycle. So the PWM high and PWM low have the same period.
I configured P26 as output and P12 (which is dual-bonded to P26 via pin 32) as input.
Then I did a busy loop with 10 iteration which reads both P12 and P26 via gpio_getPinInput() and output it via ble_trace2().
BYTE p12 = gpio_getPinInput(GPIO_PIN_12/16, GPIO_PIN_12%16);
BYTE p26 = gpio_getPinInput(GPIO_PIN_26/16, GPIO_PIN_26%16);
ble_trace2("P12:%d P26:%d\n", p12, p26);
So this indicates that gpio_getPinInput() does return the state of a GPIO regardless of the mode the GPIO is configured to.