CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Conversion Help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Mark W



Joined: 24 May 2009
Posts: 7
Location: Wellington NZ

View user's profile Send private message

Conversion Help
PostPosted: Thu Jun 21, 2012 2:53 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jun 21, 2012 3:33 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jun 21, 2012 3:49 pm     Reply with quote

Thanks PCM,

This now compiles until I get to
Code:
p = &vram[y/8][x];

Which says too many subscripts.
Are these things just different syntax between compilers ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 21, 2012 3:53 pm     Reply with quote

1. Post a link to the source code that you are trying to convert.

2. Also post your CCS compiler version. Example of version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo
Mark W



Joined: 24 May 2009
Posts: 7
Location: Wellington NZ

View user's profile Send private message

Link to Microchip PIC18FXK20 Starter Kit
PostPosted: Thu Jun 21, 2012 7:49 pm     Reply with quote

http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en535806

I am converting the OLED drive in the demo software

I have version 4.71 of the compiler
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 21, 2012 7:54 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jun 21, 2012 8:10 pm     Reply with quote

My apologies 4.071
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 22, 2012 12:28 am     Reply with quote

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:
Code:

p = vram[y/8] + x;

This code gets the base address of the desired vram_x array, and
then adds 'x' to it. The pointer arithmetic should work OK.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group