I've got a real strange problem with a ROM array in C18. Can anyone tell me what I'm doing wrong? It seems that if I use a literal for the first array index, I get back the right value. If I use a variable, I get back the wrong value. Here's the code: void LcdDrawChar(unsigned char x, unsigned char y, unsigned char AsciiChar){ // Draw a character from bitmap using LCD bit set and bit clear commands. Assumes use of 5x7 bitmap in // charset5x7. Bitmap of char is similar to lcd in that lsb is leftmost pixel. static unsigned char rc; // Row and column counters for where we are in drawing the character static unsigned char cc; static unsigned char hhdebug1, hhdebug2, hhdebug3; static unsigned char RowBits; // pixel map for a row static unsigned char CharSetIndex; // Precalculate the index into the character map hhdebug1=AsciiChar; CharSetIndex=AsciiChar-0x20; // Precalculate the index into the character map for(rc=0; rc<7; rc++){ // for each row in the character RowBits=charset5x7[CharSetIndex][rc]; // Get bitmap for this row hhdebug2=charset5x7[0x14][rc]; for(cc=0; cc<5; cc++){ // for each col in the character LcdSetBit(x+cc, y+rc,RowBits & 0x01); // Set or clear pixel based on lsb of row RowBits=RowBits>>1; // Shift to right to get next col in lsb } } } I made the variables static so I can watch them in the watch window. The line that starts with RowBits sets RowBits to 0xff (the wrong answer) according to the watch window. The next line sets hhdebug2 to 0x08, the right answer. The watch window shows that CharSetIndex is 0x14, so I'd expect these two lines to return the same (right) answer. The charset5x7 is defined as: // 5x7 font in 7 8-bit bytes. Leftmost pixel is lsb. rom const char charset5x7[][7] ={ { 0b00000000, // 0x20 space 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000}, { 0b00000100, // 0x21 ! 0b00000100, 0b00000100, 0b00000100, 0b00000000, 0b00000000, 0b00000100}, { 0b00001010, // 0x22 " 0b00001010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000}, { 0b00001010, // 0x23 # 0b00001010, 0b00011111, 0b00001010, 0b00011111, 0b00001010, 0b00001010}, { 0b00000100, // 0x24 $ 0b00011110, 0b00000101, 0b00001110, 0b00010100, 0b00001111, 0b00000100}, { 0b00000011, // 0x25 % 0b00010011, 0b00001000, 0b00000100, 0b00000010, 0b00011001, 0b00011000}, { 0b00000110, // 0x26 & 0b00001001, 0b00000101, 0b00000010, 0b00000101, 0b00001001, 0b00000110}, { 0b00001110, // 0x27 ' 0b00001000, 0b00000100, 0b00000000, 0b00000000, 0b00000000, 0b00000000}, { 0b00000100, // 0x28 ( 0b00000010, 0b00000001, 0b00000001, 0b00000001, 0b00000010, 0b00000100}, { 0b00000010, // 0x29 ) 0b00000100, 0b00001000, 0b00001000, 0b00001000, 0b00000100, 0b00000010}, { 0b00000000, // 0x2A * 0b00000100, 0b00010101, 0b00001110, 0b00010101, 0b00000100, 0b00000000}, { 0b00000000, // 0x2B + 0b00000100, 0b00000100, 0b00011111, 0b00000100, 0b00000100, 0b00000000}, { 0b00000000, // 0x2C , 0b00000000, 0b00000000, 0b00000000, 0b00000110, 0b00000100, 0b00000010}, { 0b00000000, // 0x2D - 0b00000000, 0b00000000, 0b00011111, 0b00000000, 0b00000000, 0b00000000}, { 0b00000000, // 0x2E . 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000110, 0b00000110}, { 0b00000000, // 0x2f / 0b00010000, 0b00001000, 0b00000100, 0b00000010, 0b00000001, 0b00000000}, { 0b00001110, // 0x30 0 0b00010001, 0b00011001, 0b00010101, 0b00010011, 0b00010001, 0b00001110}, { 0b00000100, // 0x31 1 0b00000110, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00001110}, { 0b00001110, // 0x32 2 0b00010001, 0b00010000, 0b00001000, 0b00000100, 0b00000010, 0b00011111}, { 0b00011111, // 0x33 3 0b00001000, 0b00000100, 0b00001000, 0b00010000, 0b00010001, 0b00001110}, { 0b00001000, // 0x34 4 0b00001100, 0b00001010, 0b00001001, 0b00011111, 0b00001000, 0b00001000}, { 0b00011111, // 0x35 5 0b00000001, and continues on Note that the entry for 0x34 (actually 0x14 since we subtract 0x20) is indeed 0x08, as returned by the array reference with the constant. Any ideas??? Thanks! Harold FCC Rules Online at http://hallikainen.com/FccRules Lighting control for theatre and television at http://www.dovesystems.com Reach broadcasters, engineers, manufacturers, compliance labs, and attorneys. Advertise at http://www.hallikainen.com/FccRules/ . ________________________________________________________________ GET INTERNET ACCESS FROM JUNO! Juno offers FREE or PREMIUM Internet access for less! Join Juno today! For your FREE software, visit: http://dl.www.juno.com/get/web/. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu