LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-02-2009, 03:28 AM   #1
beparas
Member
 
Registered: Nov 2006
Location: Pune
Posts: 48

Rep: Reputation: 0
How to generate software event?


Hello Friends, I need your help.
I am working on linux kernel-2.6.20 for MPC8313erdb board.
I want to write a module which is given below,
When I got any signal at GPIO pin, the status of that pin will be store, and the counter will be start for 10ms. After 10ms I want to again check the status of same GPIO pin.

So is there any system call to set timer for 10ms in module programming?
Please let me know if any, how its works.

Thanks in advance

Last edited by beparas; 03-02-2009 at 10:12 PM.
 
Old 03-03-2009, 12:56 PM   #2
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Rep: Reputation: 22
On a microcontroller you have hardware -> Timers and more than one, that can emit an interrupt, if you want every 10 ms.
You have to programm that timer on your own if there is no support from linux, or you can take a timer driver/module laying arround. Maybe from the manufacture.
To programm the timer you get all information out of the datasheet. If you set up the timer right and put your interrupt handler on that interrupt, then everything should work fine on starting that timer (once).

Inside your app. you can program your own threading mechanism.
Sofware interrupts are the same as OOP (that's why OOP exists). You use an array of pointers to Objects (Events in this scope). Implement this event class in your classes so you can receive that event.
On an interrupt (hardware, irq) every event in that array is emited (called) once. You can also split and filter that irq to different events (arrays).
If you need a interrupt table then also the pointers to that events arrays are stored in an array so you can call them over a number.

If you have a realtime clock on board then every read access to it takes 1ms (that's standard)

Yes, you have to be careful with calling other things in modules, but system calls should be save (I don't have experience in that because I program my embedded systems in assembler - totally) so you could test sleep or nanosleep if supported ?

Have very much fun!

Last edited by bastl; 03-03-2009 at 05:03 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate CA help saman Linux - Wireless Networking 1 04-22-2008 05:25 AM
How to generate *.ko for 2.6 kernel kiran@ccpu Linux - Software 4 11-05-2007 11:19 PM
To generate Software Interrupt to ARM920T processor topworld Programming 0 04-11-2006 02:17 AM
how to generate .so abd_bela Programming 1 01-31-2006 04:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration