[ragel-users] Best practice: using ragel for bit-based state machines on microcontroller?
graceindustries at gmail.com
Wed Apr 29 17:51:18 UTC 2009
On Tue, Apr 28, 2009 at 3:49 PM, Jan Sporbeck <ich+lists at slashhome.de> wrote:
> Hello there!
> I'd like to use ragel to design the state machine for a microcontroller
> project (avr atmega8535) written in C.
> I think I understand how to use it for streams of char, int, etc. But
> what's the best practice to use for bit based decisions?
> I could use union..struct to pack all bits in one datatype and process
> that. But I doubt that'll yield a performant implementation.
You don't have enough space in 8535 to do all of that. Set each
byte as bool in the struct.
> I read messages on this list that ragel is used for uC projects, but no
> details how.
Depends on the compiler. If you are using GCC you have to use Ragel
in 'goto' format. The tables will not work without futher processing.
This does make the code a lot larger. It would be better to write the software
before you pick the processor, something with more memory is usually a better
choice, than the old 8535 parts.
If you are using the IAR compiler tables probably will work ok, don't
know for sure as I try to avoid IAR when I can. Don't know the state
of Imagecraft's table handling today, been long time since I used them.
> So any hints or example code to get me started is appreciated.
Sorry, boss would not like me giveing out our code.
More information about the ragel-users