Welcome, Guest

Author Topic: mmapped IO for GPIO and PWM  (Read 2260 times)

Lirezh

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
mmapped IO for GPIO and PWM
« on: April 15, 2014, 03:57:19 AM »
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

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Re: mmapped IO for GPIO and PWM
« Reply #1 on: April 15, 2014, 06:01:05 PM »
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

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: mmapped IO for GPIO and PWM
« Reply #2 on: April 16, 2014, 02:57:48 AM »
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

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +7/-0
Re: mmapped IO for GPIO and PWM
« Reply #3 on: April 16, 2014, 03:35:26 PM »
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.
« Last Edit: April 16, 2014, 03:41:34 PM by Mouchon »