[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] General programming question/GPS parsing

From: Bernard Fouché
Subject: Re: [avr-gcc-list] General programming question/GPS parsing
Date: Wed, 02 Mar 2005 18:11:20 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Matthew MacClary a écrit :

  I have a general question, right now we parse the GPS sentence

inside the USART interrupt.  I would like to have the interrupt only
receive the data and write it to a buffer, how would I then tell
another function to parse the buffer with interrupts enabled?  Can I
just do a sei() inside of SIGNAL to turn interrupts on and then call
the parsing function?



Hi Matt.

I think it's better to keep interrupts the shortest possible. What I'm doing on our current project:

- A character is received under interruption from the USART and stored in a circular buffer with a read and a write pointer. - The main program loop polls the buffer to see if a character is available or not. If a character is available, it is retreived and parsing is done.
- If parsing is completed for a sentence, actions are done.

So that's the typical sheme, with a main central loop and buffers managed by interrupt driven routines that only get/put characters in circulars buffers. All 'intelligent' processing is done in the central loop if there is enough data, code is kept minimal inside routines called by interrupts.

Of course interrupt management is important since you don't want to process an incomming character (and/or an outgoing character if you are transmitting also under interrupt) while the main central loop manipulates the read/write pointer values of the circular buffer. (for instance)

Don't forget to use the 'volatile' keyword on variables that can be changed in the main program loop and in a routine activated by an interruption. (again the read/write pointer values and eventually the count of available characters in the buffer or anything else involved in a similar way)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]