Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC C18 Compiler Issues: Pointers, Function Prototypes

Status
Not open for further replies.

Fred.Amoson

New Member
I am working on a new project with the C18 compiler. For the most part things are going well, but I have ran into a few glitches that I cannot figure out.

One small thing that I can't figure out is that everytime I compile I get:

"Warning [2058] call of function without prototype"

Even though the function being called does have a prototype. For instance, on the line where the function initializeLCD() is called, it gives me that warning, however in my header file I have the line:

void initializeLCD();

and the header file is included in the project. Anyone know what the deal with this is?

Also, I can't seem to get pointers working in C18. I am trying to have a globally addressable array of text that I can read to or write from any function. Any attempt at this has failed. Here is a snippet of where I define my variables:

Code:
char dataArray[] = "Text Array";
char *pData;

void main (void)
{	
	OSCCON = 0b01110000; //8MHz Clock
	pData = dataArray;

Then in a later function I set:

pData = "Testing";

But when I try to pull up pData[0] I get a 0 instead of a T. Also, dataArray is still equal to text array. I've tried a combination of & and * but I just can't seem to get it. Any help would be greatly appreciated!
 
Fred.Amoson said:
I am working on a new project with the C18 compiler. For the most part things are going well, but I have ran into a few glitches that I cannot figure out.

One small thing that I can't figure out is that everytime I compile I get:

"Warning [2058] call of function without prototype"

Even though the function being called does have a prototype. For instance, on the line where the function initializeLCD() is called, it gives me that warning, however in my header file I have the line:

void initializeLCD();

and the header file is included in the project. Anyone know what the deal with this is?
Use the 'void' type when you declare functions with no arguments; that should fix the problem.

Code:
void initializeLCD(void);
 
Fred.Amoson said:
...
Also, I can't seem to get pointers working in C18. I am trying to have a globally addressable array of text that I can read to or write from any function. Any attempt at this has failed. Here is a snippet of where I define my variables:

Code:
char dataArray[] = "Text Array";
char *pData;

void main (void)
{	
	OSCCON = 0b01110000; //8MHz Clock
	pData = dataArray;

Then in a later function I set:

pData = "Testing";

But when I try to pull up pData[0] I get a 0 instead of a T. Also, dataArray is still equal to text array. I've tried a combination of & and * but I just can't seem to get it. Any help would be greatly appreciated!
It's a Ha'va'd architecture man. There are two memory types. Program memory is as wide as the instruction word and techniques vary as to how a "constant character string" is packed into program memory. Then there is data memory which is as wide as the registers, typically 8 bits. Now a pointer to a constant character string in Program memory is a very different animal from a pointer to a character string in data memory.

I would look for keywords that help the compiler determine what kind of memory the pointer is pointing at.

I went to Princeton and we treat all memory the same. We don't have such problems.
 
Pointers on a pic are one of the most confusing things I've come across. The only way to get a string from ROM into RAM is to copy it manually.

Here's my understanding of how to manipulate strings.
Code:
ram char dataArray[20]="Test Data";
ram char *pData;

//copy string from rom to ram.
void SetString(ram char* RamString,rom char* RomString){
    do{
        *RamString++=*RomString;
    }while(*RomString++!=0);
}

//in main you can then have,
static rom char HW[]="Hello world";

//You can then do,
    SetString(dataArray,(rom char*) "Hello World");
//or
    SetString(dataArray,HW);

//you can also do,
    pData=dataArray;
    chr=*pData;
    SetString(pData,(rom char*) "Somert else.");
You have to remember that the compiler wants (has) to treat all strings as constants and stick them in ROM.

Mike.
 
Last edited:
So are "ram" and "rom" the keyword qualifiers in the C18 compiler?
 
Fred.Amoson said:
Thanks for the info Papabravo, that helps a lot, I will post back when I figure it out!
No problem -- glad to be of assistance.
Good Luck
 
Papabravo said:
So are "ram" and "rom" the keyword qualifiers in the C18 compiler?
Kind of, there are actually four different types of pointer, and there not interchangeable.
near rom
far rom
near ram
far ram

But generally you can just use rom and ram.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top