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

issue with array

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



Joined: 03 Mar 2008
Posts: 55

View user's profile Send private message

issue with array
PostPosted: Sun Feb 08, 2009 8:40 am     Reply with quote

hello,

i must display time on a graphical LCD so o created big font.
i have a array wich is 800 long.

and why when i want to read array[256] my array is returning me array[0], or when i want to read array[257] i get array[1]

256,257, etc are stored in a "long" variable

this is my array :

Code:

const int8 font20x32[] = {
0x00,0x80,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0x7E,0x3E,0x3E,0x7E,0xFC,0xFC,0xF8,0xF8,0xF0,0xE0,0x80,0x00, //0-1
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, //0-2
0x00,0x0F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFC,0xF0,0xE0,0xE0,0xF0,0xFC,0xFF,0xFF,0xFF,0x7F,0x3F,0x0F,0x00, //0-3
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00, //0-4

0x00,0x00,0x80,0xC0,0xE0,0xE0,0xE0,0xF0,0xF8,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00, //1-1
0x00,0x00,0x0F,0x0F,0x07,0x07,0x02,0x02,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, //1-2
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, //1-3
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00, //1-4

0x00,0xC0,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0x7E,0x3E,0x3E,0x3E,0xFE,0xFC,0xFC,0xF8,0xF8,0xF0,0xE0,0x00, //2-1
0x00,0x01,0x03,0x07,0x07,0x07,0x87,0x83,0xC0,0xE0,0xF0,0xF8,0xFE,0xFF,0xFF,0x7F,0x7F,0x3F,0x1F,0x00, //2-2
0x00,0xC0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xF7,0xF3,0xF3,0xF1,0xF0,0xF0,0xF0,0xF0,0xF0,0x00, //2-3
0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x00, //2-3

0x00,0xC0,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0x3E,0x3E,0x3E,0x7E,0xFC,0xFC,0xF8,0xF8,0xF0,0xE0,0x80,0x00, //3-1
0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x30,0x78,0x78,0x78,0x7E,0xFF,0xFF,0xFF,0xFF,0xEF,0xC7,0x01,0x00, //3-2
0x00,0x18,0x38,0x7C,0xFC,0xFC,0xFC,0xF8,0xF0,0xE0,0xE0,0xE0,0xF0,0xFF,0xFF,0xFF,0xFF,0xEF,0x0F,0x00, //3-3
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x03,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00, //3-4

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFE,0xFE,0x00,0x00,0x00, //4-1
0x00,0x80,0xE0,0xF0,0xF8,0xFC,0x7E,0x3F,0x1F,0x0F,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00, //4-2
0x00,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x0F,0x00, //4-3
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x00,0x00,0x00, //4-4

0x00,0x00,0xC0,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x00, //5-1
0x00,0x00,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1C,0x1E,0x1E,0x1E,0x7E,0xFE,0xFE,0xFC,0xFC,0xF8,0xC0,0x00, //5-2
0x00,0x18,0x7C,0x7C,0xFC,0xFC,0xFC,0xF8,0xF0,0xE0,0xE0,0xE0,0xF8,0xFF,0xFF,0xFF,0x7F,0x3F,0x0F,0x00, //5-3
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x03,0x03,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00, //5-4

0x00,0x00,0xC0,0xE0,0xF0,0xF8,0xF8,0xFC,0x7C,0x3E,0x3E,0x3E,0xFE,0xFC,0xFC,0xF8,0xF8,0xF0,0x60,0x00, //6-1
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x78,0x3C,0x3C,0x3C,0x7C,0xF8,0xF9,0xF9,0xF9,0xF0,0xC0,0x00, //6-2
0x00,0x07,0x1F,0x7F,0x7F,0xFF,0xFF,0xFF,0xF0,0xE0,0xE0,0xE0,0xF0,0xFF,0xFF,0xFF,0xFF,0x7F,0x1F,0x00, //6-3
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00, //6-1

0x00,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0x7C,0x00, //7-1
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xF8,0xFE,0xFF,0xFF,0x7F,0x1F,0x07,0x03,0x00,0x00,0x00, //7-2
0x00,0x00,0x00,0x00,0x00,0xF0,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xF3,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //7-3
0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //7-4

0x00,0xC0,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0x7E,0x3E,0x3E,0x3E,0x7E,0xFC,0xFC,0xF8,0xF0,0xE0,0xC0,0x00, //8-1
0x00,0xC1,0xE7,0xFF,0xFF,0xFF,0xFF,0xFF,0x7E,0x3C,0x3C,0x7C,0xFE,0xFF,0xFF,0xFF,0xFF,0xE7,0xC1,0x00, //8-2
0x00,0x1F,0x7F,0xFF,0xFF,0xFF,0xFF,0xF8,0xF0,0xE0,0xE0,0xF0,0xF8,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x00, //8-3
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x03,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00, //8-4

0x00,0xC0,0xF0,0xF0,0xF8,0xF8,0xFC,0x7C,0x3E,0x3E,0x3E,0x7E,0xFC,0xFC,0xF8,0xF8,0xF0,0xE0,0x80,0x00, //9-1
0x00,0x3F,0x7F,0xFF,0xFF,0xFF,0xF8,0xF0,0xE0,0xE0,0xE0,0xF0,0x78,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, //9-2
0x00,0x10,0x78,0x7C,0xFC,0xF9,0xF9,0xF9,0xF1,0xE1,0xE1,0xF0,0xFC,0xFF,0xFF,0xFF,0x7F,0x3F,0x0f,0x00, //9-3
0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //9-4
};


and here is how i tried to read my array :

Code:


#include <16F877A.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20000000)
#include <font20x32.c>

#DEFINE DB0 PIN_D0
#DEFINE DB1 PIN_D1
#DEFINE DB2 PIN_D2
#DEFINE DB3 PIN_D3
#DEFINE DB4 PIN_D4
#DEFINE DB5 PIN_D5
#DEFINE DB6 PIN_D6
#DEFINE DB7 PIN_D7
#DEFINE E PIN_E2
#DEFINE RW PIN_E1
#DEFINE RS PIN_E0

///////////////////////////////////////
void put_data(int8 data)              //
   {                                 //
   output_bit(DB0, !!(data & 1));    //decomposition d'un octet
   output_bit(DB1, !!(data & 2));    //a envoyer et placement
   output_bit(DB2, !!(data & 4));    //dur DB0 a DB7
   output_bit(DB3, !!(data & 8));    //
   output_bit(DB4, !!(data & 16));   //
   output_bit(DB5, !!(data & 32));   //
   output_bit(DB6, !!(data & 64));   //
   output_bit(DB7, !!(data & 128));  //
   delay_cycles(10);                 //
   }                                 //
///////////////////////////////////////

///////////////////////
void enable(void)    //validation
   {                 //
   output_low(E);    //
   delay_cycles(50); //
   output_high(E);   //creer une impulsion sur E
   delay_cycles(50); //
   output_low(E);    //
   }                 //
///////////////////////


void main(void) {
   long l;
   l = 240;
   while(l<321)
   {
   put_data(font20x32[l]);
   enable();
   delay_ms(1);
   l++;
   }
}



here is what i get :



do any of you know why i can't acces data wich are stored futher than 255?

thanks

CCS V4.057[/img]
_________________
yup, i know, i don't speak english very well

CCS V4.057


Last edited by sliders_alpha on Sun Feb 08, 2009 10:35 am; edited 1 time in total
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Feb 08, 2009 10:27 am     Reply with quote

If you try to set an explicite array size of 640, CCS C tells you data item too big, in other words, it don't support int8
arrays above 256 elements. An respective int32 array may be possibly a solution.
sliders_alpha



Joined: 03 Mar 2008
Posts: 55

View user's profile Send private message

PostPosted: Sun Feb 08, 2009 10:34 am     Reply with quote

inded, well, it's still too big for int32.

i'm going to use four 255 array.

thanks
_________________
yup, i know, i don't speak english very well

CCS V4.057
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