From: Dave H. <dhy...@gm...> - 2009-07-08 17:24:50
|
Hi, > Hi, I have been trying to write a program that uses the gpio-event > functionality to monitor gpio pins at a potentially high frequency. I would > like to be able to monitor at up to 27 mHz without losing events, but after > what I've done so far this seems fairly unrealistic. I'll say that's a little unrealistic. On a 600 MHz processor, that means that you need to be able to deal with each gpio event using only 22 assembly language instructions. You'll probably find this impossible to do, even if the silicon could deal with this, and you coded everything in assembler. > I have been able to > monitor frequencies of about 8 kHz accurately without losing any events, but > I am a little unclear on how the event queue actually works. Sometimes I > will run my program, with the 8 kHz frequency, and I will have no lost > events, but then if I run the program again directly after that, I will lose > events as soon as it begins. This leads me to believe that there are still > events in the queue when I start the program again, so I would like to find > out if there is a way to clear the event queue before I start the program. The problem is that other interrupts occur on the system. If any of those interrupts takes more than 125 microseconds to process (1/8000), then you will loose an event. I highly recommend that you profile how long it takes for the linux interrupt handler to fire, and then reset your expectations.... > In the gpio-event-drv.c file, there is a dequeue function, but I don't seem > to have any way of using that function in my program. Is there a way that I > can clear the queue? I'll copy in the code for my program in case anyone > has an idea on how to speed it up. Thanks for any help in advance. The event queue is a simple, circular buffer implemented using an array. The array has GPIO_EVENT_QUEUE_LEN elements in it, and there is a get index and a put index. Setting the get index equal to the put index will "empty" the queue. numEvents should also be set to zero to keep things consistant. gpio-event wasn't designed to be a high-performance driver. It was designed to allow user-mode access to gpio events, typically for dealing with user-interface type stuff. If you want high-performance stuff you really need to do everything from kernel space, and forget about involving user-space. There's too much overhead involved in the user-space to kernel space context switches. Typically, the only way you can successfully do any type of bi-banged I/O in linux is if the linux host also generates the clock which controls the "flow". If you don't have that, then I can pretty much guarantee that you will miss events. -- Dave Hylands Shuswap, BC, Canada http://www.DaveHylands.com/ |