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

Compilation error

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



Joined: 11 Mar 2008
Posts: 20
Location: Toulouse, France

View user's profile Send private message

Compilation error
PostPosted: Wed Mar 12, 2008 2:32 am     Reply with quote

Hello everybody,
first of all sorry for my bad english (I'm french) ;)

I'm trying to write on a sd card with a 18F4620, using FAT.

I want to use the ccs driver, but I've an error while I compile :

Code:
#include <18F4620.h>

#fuses XT, NOWDT, NOPROTECT
#use delay(clock = 4000000)
#use rs232(baud=38400, xmit=PIN_C6,rcv=PIN_C7)

#include<stdio.h>
#include<string.h>
#include<mmcsd.c>
#include<fat.c>

void main()
{
set_tris_b(0);

   while(1)

   {
   output_high(PIN_B1);
   delay_ms(200);
   output_low(PIN_B1);
   delay_ms(200);
   }


}


This is the begining, but at compilation I've got this message :

Executing: "C:\Program Files\PICC\Ccsc.exe" "main.c" +FH +DF +LN +T -A +M +Z +Y=9 +EA
>>> Warning 203 "main.c" Line 18(1,1): Condition always TRUE
Memory usage: ROM=0% RAM=14% - 14%
0 Errors, 1 Warnings.
Executing: "C:\Program Files\PICC\Ccsc.exe" "fat.c" +FH +DF +LN +T -A +M +Z +Y=9 +EA
*** Error 128 "D:\guillot\ecriture\string.h" Line 34(1,2): A #DEVICE required before this line
1 Errors, 0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Wed Mar 12 09:19:36 2008


But the #device PIC18F4620 is already in the 18F4620.h
And If I add #device PIC18F4620 in string.h, I've a message "#device already configured...."

I think it's a newbie problem but I cant resolve it... can you help me?

Thanks ...
Ttelmah
Guest







PostPosted: Wed Mar 12, 2008 3:24 am     Reply with quote

Are you compiling from MPLAB?.
It actually looks as if you are compiling your main.c, with all it's required includes OK, and then separately compiling fat.c, which doesn't have a processor definition, and includes string.h itself. The error is on this second compilation.
If you are working from MPLAB, then this is because fat.c, (because it has a .c extension), has 'by default' got flagged as a source file, rather than an 'header' file. In the 'files' window, you need to move the file from the 'source files' branch, to the 'header fles' branch.

Best Wishes
gremi



Joined: 11 Mar 2008
Posts: 20
Location: Toulouse, France

View user's profile Send private message

PostPosted: Wed Mar 12, 2008 3:30 am     Reply with quote

Yes, I'm compiling from MPLAB (I Use MPLAB ICD2) and you're right, fat.c is in the source file section, not in hearders.

But if I try to add fat.c as a header, MPLAB puts if automatically in the source file section.

Do I have to rename fat.c to fat.h ????
gremi



Joined: 11 Mar 2008
Posts: 20
Location: Toulouse, France

View user's profile Send private message

PostPosted: Wed Mar 12, 2008 4:47 am     Reply with quote

I renamed fat.c to fat.h and it seems to work.

I've got an other problem, trying to write on a file :
Code:

void main()
{
FILE fichier;

fat_init();


fatopen("toto", "w", &fichier);
fatputc("mytext", &fichier);
fatclose(&fichier);


And ccs returns me an error message :

*** Error 90 "main.c" Line 23(19,20): Attempt to create a pointer to a constant

I've looked to the documentation, and I've seen that :

Attempt to create a pointer to a constant

Quote:
Constant tables are implemented as functions. Pointers cannot be created to functions. For example CHAR CONST MSG[9]={"HI THERE"}; is permitted, however you cannot use &MSG. You can only reference MSG with subscripts such as MSG[i] and in some function calls such as Printf and STRCPY.


But i don't undernstant where the problem is ... can you help me???

Thanks.
Ttelmah
Guest







PostPosted: Wed Mar 12, 2008 6:02 am     Reply with quote

A search in the forum will find a lot about this. Basically, you have to remember that the PIC, has a somewhat 'odd' architecture, with the ROM memory, separate from the RAM. This means that objects in ROM, are in a different 'address space', to those in RAM, so if you declare a simple string 'constant', like "Hello", which in a normal processor, can be addressed using a pointer, in the PIC, it can't (some other compilers, have bodges to work round this).
So, you either need to copy the string constants into RAM, before using
them, or declare them as RAM variables. So:
Code:

void main() {
   FILE fichier;
   char temp_buff[10];
   char wcmd[]="w";
   fat_init();

   strcpy(temp_buff,"toto");
   fatopen(temp_buff, wcmd,&fichier);

This shows both routes to put the values in RAM.
There is a 'work around' for this, for constants, declared using the #ROM declaration, on the recent compilers.

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