yes, it is another lookup table question

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want a table with unsigned int's in program memory. This is how I declare it:

#define	baud38400	12
#define	baud19200	25
#define	baud9600	51
#define	baud4800	103
#define	baud2400	207
#define	baud1200	416
#define	baud600		832
#define	baud300		1666

// A table of the standard baud speeds for F_MCU = 8 MHz
unsigned int baudtable[] PROGMEM = \
	{baud300, baud600, baud1200, baud2400, baud4800, baud9600, baud19200, baud38400};

Then I want to access a certain element:

USART0_Init( pgm_read_word( &baudtable [5] ) );   // Set the baudrate

but this doesn't work. It compiles but the ATmega8 does not behave correctly. I bet this is really simple to fix, but I tried lots of stuff but nothing works... any ideas?
Checked all other posts on this subject, but all are dealing with unsigned char tables. And yes, I looked in the avr-libc documentation! ;)
EDIT: I just realized that this isn't the part of the code that crashes. Sorry :oops:

/Jakob Selbing