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 CCS Technical Support

ccs doesnt support this??? pointers...

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



Joined: 15 Feb 2005
Posts: 21

View user's profile Send private message Visit poster's website

ccs doesnt support this??? pointers...
PostPosted: Fri Mar 11, 2005 5:56 am     Reply with quote

Hi, im trying to make a pointer to a vector in rom memory...

function:
void gclcd_img(unsigned int16 *imgn, unsigned int8 pixl)
{
for(i=0; i<pixl; i++)
{
gclcd_data(imgn[i]);
}
}

call:
gclcd_img(img16, sizeof img16);

where img16 is:
STATIC CONST UNSIGNED INT16 img16 [12100]={0x4943,0x4123,0x4943,0x4943,0x4923,0x4923,0x4942,0x4943,0x4943,0x4943,0x4943,0x4943,0x4943..........}

How can i do that??

thanks for your replies

Jaime
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Mar 11, 2005 7:33 am     Reply with quote

No, read the manual. Pointers to constants are not allowed. Search the board for alternatives.

Here is an example where I used "Melody Pointer" as a global indicator to which constant struct I was using.
http://www.ccsinfo.com/forum/viewtopic.php?t=22010
J1M



Joined: 15 Feb 2005
Posts: 21

View user's profile Send private message Visit poster's website

PostPosted: Fri Mar 11, 2005 10:16 am     Reply with quote

Thanks for your reply, i know that ccs 'DEFECT'... i think that a pointer to a constant should be supported.. its only my opinion of course ;)

ill try with your example, thanks very much Smile

if there is any other suggestion would be very apreciated!

Reggards!
J1M



Joined: 15 Feb 2005
Posts: 21

View user's profile Send private message Visit poster's website

PostPosted: Sun Mar 13, 2005 2:28 pm     Reply with quote

i cant apply your sample...

ive trying to modify function, but no satisfy results :( ... in pseudocode this is that im trying to do:

img vector:
STATIC CONST UNSIGNED INT8 img [10000]={0x6E,0x6E,0x43,0x23,0x43,0x43,0x23,0x23.....};

call:
gclcd_img(img);

Code:

void gclcd_img()
{
   for(i=0; i<10000; i++)
   {
         gclcd_send(img[i]);
   }
}



i think that its very simple... im only have to read 10000 position of a vector in ROM memory! .......... could i do this in assembler???

thanks for your support

Jaime
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 13, 2005 2:40 pm     Reply with quote

Don't post pseudo-code. Post a real test program, with all the
CCS directives and include statements. Then we know the PIC
that you're using and the #fuses settings, etc., and we can easily
point out any errors.
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Mar 13, 2005 3:04 pm     Reply with quote

I am sorry, but I have to jump in here...I strongly object to calling it a DEFECT just because CCS doesn't support pointers to ROM. If that's the case then every compiler in the world has defects! Rather it is simply something not supported by this compiler. This (BTW) is true in some respect for every compiler in existance as far as I know, but especially true for embedded compilers due to the nature of the devices.

If you want this FEATURE then pay a lot more and get HiTech C. However, be warned, if a missing capability is a defect, there are a bunch of capabilities CCS has that Hi Tech doesn't and vice-versa. Read the compiler comparisons sometime!

Don't down CCS just because you want everything for a cheap price, but who doesn't! If that's the case I especially want my $100 Turbocad to have all the FEATURES of the $3000 Autocad I use at the office without me paying for them!!!

To everyone else, sorry for the rant...but I feel better now.

Have a nice (non-defective) day!
Smile
Guest








PostPosted: Sun Mar 13, 2005 4:57 pm     Reply with quote

bravo! dyeatman...................

ill try to explain that i wanna do, i have two images in rom memory, i havent no problem to send 1 image to the display cause i use this code..

main.c
Code:

#include <18F2520.h>

#fuses NOWDT, WDT128, H4, NOPROTECT, BROWNOUT, BORV45, NOPUT, NOCPD
#fuses NOSTVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOIESO, NOFCMEN, NOPBADEN
#fuses NOWRTC, NOWRTB, NOEBTR, NOEBTRB, NOCPB, NOLPT1OSC, MCLR, NOXINST

#use delay(clock=40000000)

#include <img.c>
#include <gclcd.h>

void main(void)
{
   setup_adc_ports(NO_ANALOGS);
   gclcd_init();
   gclcd_img(); // send image1
   while(true){}
}



the necesary extract of gclcd.h
Code:

void gclcd_img()
{
   for(i=0; i<16900; i++)
   {
      gclcd_data(img1[i]);
   }
}


my problem is that.... this way i can only send one image... and one function for image doesnt be rigth.

my initial idea was refer the image to the gclcd_img function... this way:

gclcd_img(img1);

modifing gclcd_img of course...

now i could send any image in rom memory... but ... compiler tell me an error


then, the real cuestion is... how could i do this with CCS ... im sure that there is a way...

thanks for your support and sorry for my fantastic english xDD

Jaime
Guest








PostPosted: Sun Mar 13, 2005 4:59 pm     Reply with quote

bravo! dyeatman...................

ill try to explain that i wanna do, i have two images in rom memory, i havent no problem to send 1 image to the display cause i use this code..

main.c
Code:

#include <18F2520.h>

#fuses NOWDT, WDT128, H4, NOPROTECT, BROWNOUT, BORV45, NOPUT, NOCPD
#fuses NOSTVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOIESO, NOFCMEN, NOPBADEN
#fuses NOWRTC, NOWRTB, NOEBTR, NOEBTRB, NOCPB, NOLPT1OSC, MCLR, NOXINST

#use delay(clock=40000000)

#include <img.c>
#include <gclcd.h>

void main(void)
{
   setup_adc_ports(NO_ANALOGS);
   gclcd_init();
   gclcd_img(); // send image1
   while(true){}
}



the necesary extract of gclcd.h
Code:

void gclcd_img()
{
   for(i=0; i<16900; i++)
   {
      gclcd_data(img1[i]);
   }
}


my problem is that.... this way i can only send one image... and one function for image doesnt be rigth.

my initial idea was refer the image to the gclcd_img function... this way:

gclcd_img(img1);

modifing gclcd_img of course...

now i could send any image in rom memory... but ... compiler tell me an error


then, the real cuestion is... how could i do this with CCS ... im sure that there is a way...

thanks for your support and sorry for my fantastic english xDD

Jaime
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sun Mar 13, 2005 7:03 pm     Reply with quote

What you mean it doesn't apply? The link for a program that plays tunes. The tunes are in memory (ROM) and I can play different tunes. Now in your case, you have an image instead of a tune. Instead of playing, you are displaying. Sounds like you should have been able to get something out of it.

Code:

void gclcd_img(int8 whichimage)
{
  long i;

  switch (whichimage)
  {
    case 1:
      for(i=0; i<16900; i++)
      {
        gclcd_data(img1[i]);
      }
      break;
    case 2:
      for(i=0; i<16900; i++)
      {
        gclcd_data(img2[i]);
      }
      break;
    case 3:
      for(i=0; i<16900; i++)
      {
        gclcd_data(img3[i]);
      }
      break;
  }
}
J1M



Joined: 15 Feb 2005
Posts: 21

View user's profile Send private message Visit poster's website

PostPosted: Sun Mar 13, 2005 8:12 pm     Reply with quote

hi Mark, thanks for your reply, and yes, this would be a solution to my problem Smile thanks!

but really my gclcd_img function is like this:

Code:

void gclcd_img(unsigned int8 x, unsigned int8 y)
{
   unsigned int16 IMGENDX, IMGENDY, i;

   IMGENDX = img[0];
   IMGENDY = img[1];

   gclcd_setarea(x,IMGENDX-1+x,y,IMGENDY-1+y);

   gclcd_cmd(MEMWRITE);
   for(i=0; i<((IMGENDX*IMGENDY)+2); i++)
   {
      #ifdef HIGH_COLOR
         gclcd_data(img[i+2] >> 8);
         gclcd_data(img[i+2]);
      #else
         gclcd_data(img[i+2]);
      #endif
   }
}


although ... now i have your solution, it would generate a lot of code... for this reason i was trying to use a pointer to access to the rom...
but... if there isnt any other solution... ill use it!

thanks! Smile
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