teejaydub 0 Posted February 1, 2007 Report Share Posted February 1, 2007 I've been able to use rom character arrays in other modules, but I'm having trouble with the code below. It looks correct to me, if I'm understanding the 'rom' keyword correctly. Is this a compiler bug, or am I overlooking something? Source: unsigned char crc; // CRC arrays for the nibble-wise routine. rom char* r1 = { 0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41, }; rom char* r2 = { 0x00, 0x9d, 0x23, 0xbe, 0x46, 0xdb, 0x65, 0xf8, 0x8c, 0x11, 0xaf, 0x32, 0xca, 0x57, 0xe9, 0x74 }; unsigned char crc8(unsigned char data) { unsigned char i = (data ^ crc); crc = r1[i & 0xf] ^ r2[i >> 4]; return crc; } I get these errors: failure ...\romArrayBug.c(19:8): error: failed to generate expression ...\romArrayBug.c(19:8): error: invalid operand 'r1[i & 0xf] ' ...\romArrayBug.c(19:20): error: failed to generate expression ...\romArrayBug.c(19:20): error: invalid operand '^ ' ...\romArrayBug.c(19:6): error: failed to generate expression IDE version: 6.60 Compiler: BoostC 6.60 Target device: PIC16F688 OS: XP Pro SP2 Quote Link to post Share on other sites
wally 0 Posted February 1, 2007 Report Share Posted February 1, 2007 Could this happen because of the comma after the last r1 element? Regards, Wally Quote Link to post Share on other sites
teejaydub 0 Posted February 2, 2007 Author Report Share Posted February 2, 2007 Could this happen because of the comma after the last r1 element? Regards, Wally <{POST_SNAPBACK}> No - removing the comma doesn't fix it. (And that's legal C anyway.) Quote Link to post Share on other sites
Dave 0 Posted February 2, 2007 Report Share Posted February 2, 2007 I get these errors: failure ...\romArrayBug.c(19:8): error: failed to generate expression ...\romArrayBug.c(19:8): error: invalid operand 'r1[i & 0xf] ' ...\romArrayBug.c(19:20): error: failed to generate expression ...\romArrayBug.c(19:20): error: invalid operand '^ ' ...\romArrayBug.c(19:6): error: failed to generate expression <{POST_SNAPBACK}> Missing #include <system.h> ? Regards Dave Quote Link to post Share on other sites
teejaydub 0 Posted February 2, 2007 Author Report Share Posted February 2, 2007 Missing #include <system.h> ? <{POST_SNAPBACK}> Yup! Didn't know it was required for that keyword. Thanks! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.