[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] array of pointers to functions - ok in RAM, fails in
From: |
Royce Pereira |
Subject: |
Re: [avr-gcc-list] array of pointers to functions - ok in RAM, fails in flash |
Date: |
Mon, 26 Feb 2007 02:52:27 +0530 |
User-agent: |
Opera Mail/9.10 (Win32) |
Hi David,
On Mon, 26 Feb 2007 02:07:54 +0530, David McNab <address@hidden> wrote:
> Surely it can't be too hard to place a table of function pointers into
> flash, retrieve function pointers from this table, and 'call' them.
>
I remember as a newbie to the list, I'd asked this very question a couple of
years ago. A few members kindly replied, and since then I've gone on to create
many projects implementing their advice.
Try:
void (*do_func[])(void) PROGMEM=
{ func1, func2, func3, func4, func6 };
int main(void)
{
void (*func)(void);
while(1)
{
.......
(fun= pgm_read_word(&do_func[func_no]))(); //func_no is the
element no..
.......
}
return 0;
}
Bye,
--Royce
>
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
>
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/