- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to disengage PWM and use the pin as a GPIO - input/output.
How do I do that ?
Functions:
void pwm_disableChannel(UINT32 mask);
void pwm_setReset(UINT32 mask, BOOL32 resetEnable);
only stop the PWM locking the output on high or low level.
The pwm_tones sample app conveniently disables the gpio output with:
// In state 4, disable output and the PWM entirely and insert an internal pull-down on the GPIO.
gpio_configurePin((TONES_LED1_GPIO) / 16, (TONES_LED1_GPIO) % 16, GPIO_OUTPUT_DISABLE | GPIO_PULL_DOWN, 0);
but that is not what I want. I want to reuse this GPIO, not disable it.
You can try to configure the pin back as gpio output with:
gpio_configurePin
but then when you try to set the level the output may get inverted depending on what level the PWM stopped at.
So if PWM stopped at high level later when you set 0 you will get 1, when you set 1 you will get 0.
When PWM stops at low level everything is normal.
Any idea how to properly reconfigure the pin from PWM to gpio ?
Solved! Go to Solution.
- Tags:
- 852706
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you disable GPIO then you cannot see what PWM's level is since its output is not connected to the pin.
Try to start/disable PWM until it outputs HIGH level on GPIO - if the duty cycle is 50% you have 50% chances to do that each time.
Then you can disable GPIO, enable it again and the level will be HIGH on GPIO even if you enable it as LOW.