EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Timer Interrupt And UART Interrupt

Started by rijan Shrestha August 17, 2013
I am having problem in understanding timer interrupts and its use? I mean , how it can be more useful than the delays we generaly use as
{while(int i=0;i In GSM messege or text receive do we need uart interrups? If so how it can be done?

[Non-text portions of this message have been removed]

An Engineer's Guide to the LPC2100 Series

--- In l..., rijan Shrestha wrote:
>
> I am having problem in understanding timer interrupts and its use? I mean , how it can be more useful than the delays we generaly use as
> {while(int i=0;i > In GSM messege or text receive do we need uart interrups? If so how it can be done?
>
> [Non-text portions of this message have been removed]
>

With a timer interrupt, your program could be doing something else while waiting for the event. Some programs can get by very nicely with timing loops as long as the programmer realizes that the code will probably disappear when compiler optimization is turned on. The compiler is smart enough to realize that nothing is being done inside the loop and, therefore, the loop code is useless. This has caught many programmers!

Real time operating systems will always use a timer interrupt to invoke the scheduler.

You will almost certainly need to use UART interrupts with the GSM message. You will probably set up a circular queue and as each char is received you will put it in the queue. Your mainline code will eat chars from the queue while it looks for the pattern that begins the sequence of interest.

Typically, an interrupt routine wants to be short and fast - get in, do as little as possible and get out. However, you could put some of the sentence parsing inside the interrupt handler and only queue up the information that the main code wants to see.

Since this is an obvious application, I would expect to find code somewhere on the Internet.

Richard

--- In l..., rijan Shrestha wrote:
>
> I am having problem in understanding timer interrupts and its use? I mean , how it can be more useful than the delays we generaly use as
> {while(int i=0;i > In GSM messege or text receive do we need uart interrups? If so how it can be done?
>
> [Non-text portions of this message have been removed]
>

Think of it as two people working together.

If you only have one person, then the While(...) is you watching the (...) to occur.

If you tell person TWO to watch (...) for you, then you can do something else.

When (...) occurs, he tells you that it happened (i.e. timer == zero).
Then you stop what you were doing and handle that interrupt (task). (Timer, Uart, Pin change, there are many reason to interrupt the current task)
It all depends on the peripherals inside the chosen chip.

This is the one of the many basics of micro controllers.

In a small project, where time is flexible (i.e.
the new task will get done sometime) this is not a problem.

If a task needs to be done within 10 millisecond and if you do not get it done in 11 Msec, someone may die.

Google for "real time embedded system" for more definitions.

Good Luck

don

PS: regarding uart interrupt, please ask your professor of assistance.


Memfault Beyond the Launch