interrupt handling on the pi.


7 posts
by agrico » Tue Jul 30, 2013 2:14 am
:?: I am a first-time user of both the pi and these forums, and am in serious need of help.

I need to write a routine which responds to external stimuli. It needs to be fast, as it will be used over and over--asynchronously, of course--so it should not detract (noticeably) from the main job of the computer (after all, that's what interrupts are for!).

I am used to using processors which have a definite interrupt structure--interrupt inputs, interrupt control register(s). protocol regarding the Interrupt Service Routines' placement, prioriity, and so on.

I can, unfortunately, find nothing on this subject--including instructions--, but I'm certain it must exist. If someone could point me in the right direction to solve my problem I would be deeply in your debt.

Best regards---
Posts: 10
Joined: Tue Jul 30, 2013 1:29 am
by jaynvt » Tue Jul 30, 2013 12:57 pm
Try https://developer.ridgerun.com/wiki/index.php/Gpio-int-test.c .. sample and more at that website..

Cheers..

jay
Posts: 5
Joined: Tue Dec 11, 2012 2:47 pm
by agrico » Wed Jul 31, 2013 2:01 am
jaynvt wrote:Try https://developer.ridgerun.com/wiki/index.php/Gpio-int-test.c .. sample and more at that website..

Cheers..

jay


Thank you for your rapid response, Jay.; it is deeply appreciated.

All attempts at writing interrupt handlers seem to concentrate on software solutions.
Can anyone answer my suspicions that, perhaps, the RPi was not intended to be used in real-time embedded applications?

Again, many thanks--in advance. Answers to questions such as these go a long way towards helping me understand the philosophy of the device, which is as important as learning the hardware and software.
Posts: 10
Joined: Tue Jul 30, 2013 1:29 am
by rpdom » Wed Jul 31, 2013 4:15 am
agrico wrote:Can anyone answer my suspicions that, perhaps, the RPi was not intended to be used in real-time embedded applications?


Of course it wasn't. It is advertised as being an educational computer, not a micro-controller or embedded system.

However, if you really want to do embedded things, you can. The best way to do this and have full control is to forget the OS and write ARM code to handle what you need. There are lots of interrupt functions available, timers, gpio, exception handlers etc. You just have to code it all yourself.

I started with the "Baking Pi"course http://www.cl.cam.ac.uk/freshers/raspbe ... orials/os/ and moved on from there to my own ideas and projects. Still small, but gradually building up a library of routines I can use.
User avatar
Posts: 4122
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK
by agrico » Wed Jul 31, 2013 3:52 pm
Thank you, rpdom.

The RPi is an outstanding device, and I'm going to stick with what it was intended for.
I plan to use it to teach programming, operating systems, and--via the many excellent DIY add-ons available--proper soldering techniques.

And thank you for the link to additional programming information.

Agrico--
Posts: 10
Joined: Tue Jul 30, 2013 1:29 am
by RBISWASX » Thu Jan 09, 2014 5:41 pm
Hi,

I have recently completed this small project on a simple Character Device Driver, in which i am requesting for an interrupt and registering it with the Kernel,with an interrupt handler, 'r_irq_handler', using 'request_irq' function. The interrupt is external and is given to GPIO Pin, hence had to memory map the GPIO Base Register using 'ioremap'. A lot more info can be found from my Blog:
http://blogsmayan.blogspot.in/p/program ... ry-pi.html

Thanks,
Rajiv.
Posts: 2
Joined: Thu Jan 09, 2014 5:30 pm
by RBISWASX » Sun Jan 26, 2014 12:22 pm
I have yet recently implemented, Bottom Half processing in the Interrupt Handler using TASKLETS in my Project..Since Interrupts are extremely Time Critical hence,processing part inside the Interrupt Handler should be postponed at some later interval of Time,when the Kernel schedules it for Running. Thus,the Top half runs in the Interrupt context,while the Bottom Half runs in Kernel Context,via a Tasklet Handler through TASKLETS...More info updated along with resources and source code,here on my Blog Page:
http://blogsmayan.blogspot.in/p/program ... ry-pi.html
Posts: 2
Joined: Thu Jan 09, 2014 5:30 pm