Re: Do I need a RTOS?
- From: Rich Webb <bbew.ar@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 23 Dec 2008 15:15:07 -0500
On Tue, 23 Dec 2008 13:10:20 -0600, "eeboy" <jason@xxxxxxxxxxxxxxxx>
wrote:
I am bringing up my first ARM project (based on LM3S1439) and am looking
for some advice. In my particular target application the processor will be
communicating with several peripherals via SPI (2) and UART, maintaining a
file system, keeping track of time and date as well as performing a lot of
GPIO manipulation. The board is also designed with a few external
communications ports so that future additions can be accommodated.
I can see lots of wait states in the manipulation of the GPIO. For example
I might have a function that sets a pin, waits for 500ms, then clears a
pin. I could probably get away with software delays at this moment but,
given the fact that the design can scale, I don't want to introduce this
inefficiency now only to have to remove it a few months down the road. That
500ms could be precious later on. I have several timers at my disposal but
I can foresee 'running out' in the future. I can think of some elaborate
solutions to this problem but it makes for messy code.
In general I was thinking I could implement a system tick which generated
an interrupt at a known interval (say 1ms). Upon each tick, I could examine
counters associated with the periodic tasks to see if they are due for
execution. The random interrupts would be handled by the specific interrupt
handler for that peripheral (example UART receive). That seems straight
forward to me. However, how best handle (cleanly) the toggling of a pin
after a certain delay? It's not a periodic task.
Should I use a full blown RTOS? If not how should I structure my
application? I've had a look at FreeRTOS but it looks to be much more than
I need and slightly intimidating.
I still like John Larkin's comment from
<ioekp314l52vs01sv62ec19s5d82agr84k@xxxxxxx>
'If ever you assign a programmer to do a deep-embedded app, and he says
"first, we'll have to write/buy an rtos", fire him instantly.'
The whole thread that contains that posting would be germane. You can
use the message ID above to hit the advanced search at groups.google.com
and bring up the archived thread.
With regards to the pin toggle, it depends somewhat on what exactly 500
msecs is: "about half a second" or "500 msec +/- 1 usec."
With no other constraints, I'd do as you are close to suggesting: have
the function set the GPIO pin and also set a tick register to (using
your numbers) 500. When the ticker counts down to zero, reset the GPIO.
You could do the decrement-test-reset in the timer interrupt or have
that isr touch a master tick and let your main loop observe that event
and handle any periodic housekeeping.
Throw the characters from the UART's isr into FIFOs and handle them when
nothing else is going on.
A reasonable overall approach is a main loop with a state machine
(switch statement) followed by any "do every time" event handlers, like
a switch debouncer.
--
Rich Webb Norfolk, VA
.
- References:
- Do I need a RTOS?
- From: eeboy
- Do I need a RTOS?
- Prev by Date: Re: USART communication in PIC
- Next by Date: Re: Do I need a RTOS?
- Previous by thread: Do I need a RTOS?
- Next by thread: Re: Do I need a RTOS?
- Index(es):
Relevant Pages
|