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

Passing data using pointers on a pic16f917

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



Joined: 23 Jan 2007
Posts: 12

View user's profile Send private message

Passing data using pointers on a pic16f917
PostPosted: Sun Jan 28, 2007 7:41 am     Reply with quote

Hi

I'm working on a mechanically scanned display. my problem is that when i look through the string and point to the constant array the out put i get is wrong. my display function was tested separate and it works, i would believe my error is in my character processing function.

Could some one please help, my code can be seen below.


Code:


#include <16F917.H>
#include <CTYPE.H>
#fuses INTRC_IO,NOPROTECT,NOWDT,PUT
#use delay(clock=8000000)
#use standard_io(a)
#use standard_io(b)
#use standard_io(c)
#use standard_io(d)
#case

//**************************************************************************************************
// Global variables
//**************************************************************************************************

int length;
int colour;
int16 stringptr;

//**************************************************************************************************
//16X10 font map
//**************************************************************************************************

const unsigned int16 A[10] = {0xFFF8, 0xFFFC, 0x0186, 0x0183, 0x0181, 0x0181, 0x0183, 0x0186, 0xFFFC, 0xFFF8}; //A
const unsigned int16 B[10] = {0xFFFF, 0xFFFF, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xE3C7, 0x7FFE, 0x3E78}; //B



const unsigned int16 Z[10] = {0xF003, 0xF803, 0xCC03, 0xC603, 0xC383, 0xC1C3, 0xC063, 0xC033, 0xC01F, 0xC00F}; //Z
const unsigned int16 Number[10][10] =
   {
      {0x3FFC, 0x7FFE, 0xC00F, 0xC03B, 0xC1E3, 0xC783, 0xDC03, 0xF003, 0x7FFE, 0x3FFC} //0
      �


      {0x307C, 0x60FE, 0xC1C7, 0xC183, 0xC183, 0xC183, 0xC183, 0xE3C7, 0x7FFE, 0x3FFC} //9
   }; // number array


//**************************************************************************************************
// Message
//**************************************************************************************************

const int16 msg1[] ={"AB 12"};


//**************************************************************************************************
// Output function
//**************************************************************************************************

void display(int top, int bottom)
{
   switch (colour) {
      
      case 1:      // outputs red   
         
         output_a(top); // display on the topline in red
         output_b(bottom); // display on bottomline in red
         delay_ms(2000);
         
      break;

      case 2:       // outputs green
         
         output_c(top); // display on the topline in green
         output_d(bottom); // displays on bottomline in green
         delay_ms(2000);
         
      break;

      case 3:         // outputs yellow
                  
         output_a(top); // display on the topline in red
         output_b(bottom); // display on bottomline in red
         output_c(top); // display on the topline in green
         output_d(bottom); // displays on bottomline in green
         delay_ms(2000);
   
      break;

      default:
         colour = 1;
      break;
   }

}

//**************************************************************************************************
// Character check
//**************************************************************************************************

void Char_prosessing(int16 *charptr)
{
   length = 0;
   
   if (isalpha(charptr))
   {
      if (length <= 10)
      {
         display(make8(charptr[length],0), make8(charptr[length],1)); // splits the 16bit value into 2 8bit values and displays
         length++;
         
      } // end if   
      else
      {
         display(0x00, 0x00);
      }
      
   }
   else if (isdigit(charptr))
   {
      if (length <= 10)
      {
         display(make8(Number[charptr][length],0),make8(Number[charptr][length],1)); 
         length++;
         
      } // end if   
      else
      {
         display(0x00, 0x00);
      }
   }
   else if (isspace(charptr))
   {
      if (length <= 10)
      {
         display(0x00, 0x00);
         length++;   
      } // end if   
   }
}



//**************************************************************************************************
// Main Program
//**************************************************************************************************

void main()
{
   setup_lcd(LCD_DISABLED);  // disables lcd display to access digital outputs   
   length = 0;
   colour = 1;
   stringptr = 0;
   
   for (;;)
   {
      if (msg1[stringptr] != '\0')
      {
         Char_prosessing(msg1[stringptr]);
         stringptr++;
      } // end if   
      else
      {
         stringptr = 0;
         if (colour <= 3)
         {
            colour++;
         } //end if
         else
         {
            colour = 1;
         } //end else
         
      } //end else
   }

}


Compiler version : 3.228

Thanks
Ttelmah
Guest







PostPosted: Sun Jan 28, 2007 10:09 am     Reply with quote

RTFM......
CCS, doeas not support pointers to constants. ou can either declare the data in RAM (get rid of the const keyword), or you have to access the array directly, not using pointers.

Best Wishes
brood



Joined: 23 Jan 2007
Posts: 12

View user's profile Send private message

PostPosted: Tue Jan 30, 2007 5:27 am     Reply with quote

Is there another way of doing the above without creating huge arrays in the ram? Because the PIC16F917 doesn't have enough ram to accomplish that.

Thank you in advance
Ttelmah
Guest







PostPosted: Tue Jan 30, 2007 5:35 am     Reply with quote

Declare the array usng #ROM (which will directly store the sequence of bytes in memory), at a 'known' location (fixed by you), and then access it using the 'read_program_memory' function. The 16F914, is one of the few '16' chips, that supports doing this.

Best Wishes
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