-
1. Re: Switching pins between modes.
Apr 17, 2017 2:52 PM (in response to WalkingThrough)This message was posted on behalf of Intel CorporationHello Mark,
Thanks for reaching out!
The following is a simple script I wrote that successfully uses PWM and then GPIO functions on the same pin. I tested this successfully on a LED:
#include <unistd.h>
#include "mraa.h"
int
main()
{
mraa_init();
//! [Interesting]
mraa_pwm_context pwm;
pwm = mraa_pwm_init(26);
if (pwm == NULL)
{
return 1;
}
mraa_pwm_period_us(pwm, 200);
mraa_pwm_enable(pwm, 1);
float value = 0.0f;
int count = 0;
while (count < 250)
{
count = count + 1;
value = value + 0.01f;
mraa_pwm_write(pwm, value);
usleep(50000);
if (value >= 1.0f)
{
value = 0.0f;
}
float output = mraa_pwm_read(pwm);
printf("PWM value is %f\n", output);
}
mraa_gpio_context gpio;
int ledstate = 0;
gpio = mraa_gpio_init(26);
mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
count = 0;
while(count < 5)
{
count = count + 1;
ledstate = !ledstate;
mraa_gpio_write(gpio, ledstate);
sleep(1);
}
return 0;
}
I hope this simple code helps you,
Pedro M. -
2. Re: Switching pins between modes.
WalkingThrough Apr 21, 2017 12:14 AM (in response to Intel Corporation)Hello Pedro -
I take your code, compile with the following: gcc file.c -o file -lmraa
It compiles no problem, not one squeak out of the toolchain.
I run your code: sudo ./file
There is the PWM output followed by a toggling bit. Okay, that works.
Run it a second time.
I don't see any PWM output. Toggling, yes. PWM, no.
Except. I reboot the Joule. Then re-run the program.
There is the PWM output. Followed by toggling.
But there's no PWM output. when run a second time. There is toggling.
If your code runs multiple times and always produces PWM followed by toggling then I have a different problem. May I ask which OS you're running? And which version of MRAA?
Here, uname -a reports:
Linux Joule 4.4.0-1000-joule #0+joule12-ubuntu SMP PREEMPT Fri Jan 6 04:28:41 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
mraa-gpio version reports
Version 1.6.1 on INTEL JOULE EXPANSION
Mark
-
3. Re: Switching pins between modes.
Apr 21, 2017 12:58 PM (in response to WalkingThrough)This message was posted on behalf of Intel CorporationI just tested this again on my Joule and I'm having the same behavior as you. PWM works only the first time, I'm not sure what might be happening. You see, I wrote that script a while ago, originally for a test on my Edison and I worked with no issues, PWM continued to work without any problems. So, I took that code, I slightly modified it to work on Joule and I only tested it once on Joule to make sure it worked before sharing it with you. So, I completely missed this issue.
Please let us investigate about this behavior and we'll get back to you once we have any useful update.
Pedro M. -
4. Re: Switching pins between modes.
WalkingThrough Apr 23, 2017 8:53 AM (in response to Intel Corporation)Hello Pedro -
Thank you. Am looking forward to some kind of resolution or workaround.
The alternative is connecting PWM0 to the input of a 2-input NAND gate with the other input connected to another GPIO. But I'm a little short of GPIOs... and would have to add more hardware elsewhere.
Your time is appreciated.
Mark
-
5. Re: Switching pins between modes.
Apr 24, 2017 12:54 PM (in response to WalkingThrough)This message was posted on behalf of Intel CorporationHello Mark,
We completely understand your situation. I would like to point out that we are currently working on this. It is really helpful that you highlighted this behavior so we can work on preventing it. Right now, we have no updates but as soon as we know anything new, we'll make sure to share it with you.
Pedro M. -
6. Re: Switching pins between modes.
May 24, 2017 1:40 PM (in response to Intel Corporation)This message was posted on behalf of Intel CorporationHello Mark,
Thank you for your interest in Joule.
We would like to offer our sincere apologies for delaying a response to your issue. We have confirmed the issue you brought to our attention and are working diligently to resolve it. Unfortunately, we do not have an ETA for release.
Pedro M. -
7. Re: Switching pins between modes.
WalkingThrough May 27, 2017 12:58 PM (in response to Intel Corporation)Hello Pedro -
At the moment, a "temporary" work-around is in place: don't use a PWM output as a GPIO. It took some convincing of the HW engineer to design in... then I showed the group your note of April 24 and that settled the matter.
Regards,
Mark