mmapped IO for GPIO and PWM

Started by Lirezh, April 15, 2014, 03:57:19 AM

Previous topic - Next topic

Lirezh

Hello,
I have the Lime board and I need to control multiple PWM channels through C.
I want a very fast method to change the duty cycle (the pulse on width in ns).

I read it should be possible through memory mapped IO but found nearly nothing related to the olimex board I have, all the world focuses on raspbery and bbb:/

My question:
Is it possible to directly control these properties ?
Has someone done this already?
A c code example would be awesome!

N8body

The Olinuxino Board has only 2 native PWMs,you can control there with:
https://github.com/dwilkins/pwm-sunxi( the kernel module should be installed as well if your using the stock debian)

If you need more PWM Output,you should use some dedicated Microcontroller like the Arduino Nano(cost around 3 Euro on Ebay). You can program it on the Fly and connect it via UART to the Board.

I have tried to Bitbang PWM but was unsucessful cause of the Jitter:
https://github.com/N8body/Servo_c
You can have a try on it.




Lirezh

Thanks for your response!

Strange that there are only two PWMs, that makes it useless for that purpose anyway as I need at least 4.

Bitwise control is indeed useless, I read a blog about someone who tried it. He even installed a realtime timer kernel module. He was able to get a good PWM but when the CPU got stressed it failed again.


What I wonder: Shouldn't it be possible to control the PWM geature through /dev/mem ?

I will do as you suggested, I have some spare tiny atmega128 board which probably will be fine for that.
But still I would really like to know if there is really no way to control a module like PWM directly through the memory mapping. Through kernel module/file based is likely with a large cpu overhead.

Mouchon

#3
You can may be try this implementation
https://github.com/lephiloux/soft-bam
this is a kernel module that implement bit angle modultation.
or this http://www.acmesystems.it/soft_pwm linux kernel module

I have to admit that i don't really test it on very stressed environement but i'am interested by your experiment.

kr

Philippe.