LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Ti AM335x -- Embedded Linux -- Interrupts (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/ti-am335x-embedded-linux-interrupts-4175627420/)

TMJJ 04-11-2018 02:20 AM

Ti AM335x -- Embedded Linux -- Interrupts
 
Dear all,

Short intro of my problem. On my embedded system I'm reading receiving and sending can messages. For those can messages there needs to be a timed sequence.

I have more experience with microcontrollers, where you have the abbility to make use of time based interrupts. So my first though is, let's used time based interrupts to time can messages. I don't know if it is even possible to do this in embedded Linux.

So I will briefly explain the can sequence.

1 -> cansend 712#00
2 -> Wait until can message 000#01.12 is received
3 -> Wait until can message 712#1B is received. At the same time, run a timer of 0.06s .

--> if can message 712#1B is received --> send 712#05
--> if timer with 0.06s is finished, interrupt everything and send can message 192#...data...

So how should I program the "time based interrupt" if possible.

Thanks in advance,
Kind regards,
TMJJ

Mara 04-17-2018 02:52 PM

Hello,
Under embedded Linux you can do it easily. The only difference with RTOS is that you don't fire an interrupt directly. You just says Linux that you want some work to be done at certain time.

An example of what you can do: create a workqueue for all type of delayed work and when you want to run a timer you use:

/**
* queue_delayed_work - queue work on a workqueue after delay
* @wq: workqueue to use
* @dwork: delayable work to queue
* @delay: number of jiffies to wait before queueing
*
* Equivalent to queue_delayed_work_on() but tries to use the local CPU.
*/
static inline bool queue_delayed_work(struct workqueue_struct *wq,
struct delayed_work *dwork,
unsigned long delay)
{
return queue_delayed_work_on(WORK_CPU_UNBOUND, wq, dwork, delay);
}



As a comment, to convert from jiffies to seconds it's enough to know that HZ is one second in jiffies. You can divide it to get the delay you want.

rocq 04-26-2018 02:01 AM

Hi TMJJ,

If you have tight timing requirements I would advise you to use the realtime kernel instead.


All times are GMT -5. The time now is 09:39 PM.