I just wanted to add that I tried this code also with the arduino IDE from Intel and check the output for generating pwm this way and the generated signal is not clean at all.
Thank you but it's not what i'm looking for. You can't make a long pulse then a short pulse with pwm and that's why people who use microcontroller are doing it manually like I said in my first post.
I just had the same need today and am wondering if you found a solution yet?
Given that the Edison is running a 'standard' Linux distro (i.e. not real-time) on the Atom cores I suspect that it's going to be quite difficult to get the precision needed for switching I/O pins from within the O/S. Perhaps one could read the Time Stamp Counter (ref RDTSC) in a tight loop to try to precisely time the I/O output, but you'd have to be prepared for the O/S to interrupt the process and re-start the program sequence if that happens.
I suspect the "right" solution would be to control the I/O from the the Quark microcontroller on the Edison. Problem is, when the Edison came out Intel was saying that the Quark would be "initially disabled". Not sure what that really means, but I can't find any docs which say how to use it.
Still looking for a solution (short of converting my design to an Arduino or small FPGA)
Unfortunatly I haven't found a solution yet and also gave up.
I tried so many different things in order to do this (including the rdtsc loop) but it's still too expensive. I've succeed to generate an almost stable pwm signal of 20 ms period and 0.9 ms of duty cycle.
The Quark core can't be used yet and it will be in the next release (I don't know when it will be). But just think about the times. The quark runs at 100MHz, so every cycle takes 10ns.
In order to generate a signal with an error of 150ns you need to run your loop in 15 cycles. Probably impossible.
I've tried with some NOP but the time that takes the gpio function to up or down a pin (from mraa) is way to slow in order to this.
Last solution in my mind is to do something like a driver or something but I can't find any documentation about how to do this.
I guess the easiest way is to buy a ledstrip with a clock wire and use I2C or find a way to do it in hardware (unfortunatly it's not my speciality).
Does anybody solved that problem?
Why don’t you try using GPIO toggling via Linux? Take a look at the GPIO table here https://communities.intel.com/docs/DOC-23158 .
Also take a look at this link https://github.com/muzzley/muzzley-intel-iot-led-strip . There you’ll find instructions on how to use a digital led strip with Edison. Take a look at it and let me know if this helps.
Thank you for your answer.
This library (muzzley-...) is used for a ledstrip using SPI which is not my case.
What do you mean by GPIO toggling via linux? Is it the same thing than what I said in my first post but by doing echo 1 > /sys/class/gpio/XX/value then echo 0 > .... ?
Isn't it the same thing?
Thank you again for your help =) .
Yes, go ahead and try it and let us know your results.