View previous topic :: View next topic |
Author |
Message |
Mark W
Joined: 24 May 2009 Posts: 7 Location: Wellington NZ
|
Conversion Help |
Posted: Thu Jun 21, 2012 2:53 pm |
|
|
Hi All,
I have a Microchip 18F46K20 starter board and i am am attempting to convert the OLED driver for CCS. I have completed most of the conversion but am stuck on the following: Code: |
void putpixel_vram(unsigned char x,unsigned char y,unsigned char color)
{
unsigned char *p;
char m = 0x01 << (y%8);
p = &vram[y/8][x];
if(color)
*p |= m;
else
*p &= ~m;
} |
I get a message in the line char m = 0x01 << (y%8);
saying expression must evaluate to a constant. It may be simple but I dont understand what this means.
Any help would be welcome.
Cheers
Mark |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 21, 2012 3:33 pm |
|
|
Put the declaration of 'm' and the assignment on separate lines:
Quote: |
unsigned char *p;
char m;
m = 0x01 << (y%8);
|
|
|
|
Mark W
Joined: 24 May 2009 Posts: 7 Location: Wellington NZ
|
|
Posted: Thu Jun 21, 2012 3:49 pm |
|
|
Thanks PCM,
This now compiles until I get to
Which says too many subscripts.
Are these things just different syntax between compilers ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Mark W
Joined: 24 May 2009 Posts: 7 Location: Wellington NZ
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 21, 2012 7:54 pm |
|
|
Quote: | I have version 4.71 of the compiler |
There is no such version. Did you look at the link I provided ? |
|
|
Mark W
Joined: 24 May 2009 Posts: 7 Location: Wellington NZ
|
|
Posted: Thu Jun 21, 2012 8:10 pm |
|
|
My apologies 4.071 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 22, 2012 12:28 am |
|
|
Quote: |
This now compiles until I get to
p = &vram[y/8][x];
Which says too many subscripts.
|
I think you can do a work-around by substituting this line for it:
This code gets the base address of the desired vram_x array, and
then adds 'x' to it. The pointer arithmetic should work OK. |
|
|
|