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

Q> about function calling

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



Joined: 03 Jun 2011
Posts: 2

View user's profile Send private message

Q> about function calling
PostPosted: Fri Jun 03, 2011 2:00 am     Reply with quote

I keep getting the error "Function used but not defined: ...time SCR=1944"

Here is the code:

Code:

#include <16F877A.h> //Initialization
#include <stdio.h>
#include <time.h>
#include <string.h>
#fuses HS, NOWDT, NOPROTECT, NOLVP, PUT
#use delay (clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#use i2c(master, sda=PIN_C4, scl=PIN_C3, FAST=100000)

time_t time(time_t * timer);
struct_tm * localtime ( time_t * timer );

void main()
{ //Start of Main Program

int sec;
int min;
int hrs;
int day;
int month;
int yr;
int dow;

time_t curtime;
struct_tm *t;

curtime=time(NULL); *the error points here and...
t = localtime (&curtime); *here
}


this is just a bit of the program but I think those are not related much so the only important aspects were just posted Smile

thank you in advance to those who would reply
Ttelmah



Joined: 11 Mar 2010
Posts: 19549

View user's profile Send private message

PostPosted: Fri Jun 03, 2011 2:17 am     Reply with quote

Read the header of the time.h file:

"/// This file only provides the prototypes and definitions needed to ///
/// proved a time alogrithm that follows the C standard library. You ///
/// also need to include/link the actual library that performs the time ///
/// base. As of this writing CCS provides such a library, rtctimer.c, ///
/// which performs the needed timebase on Timer2. You may see a similar ///
/// library for the dsPIC which has an internal RTC. "

Third line.
You have included the prototype function (twice - you have duplicated the definition in your own code), but nowhere are you including the actual function.....

Best Wishes
Ivalex



Joined: 03 Jun 2011
Posts: 2

View user's profile Send private message

PostPosted: Fri Jun 03, 2011 3:04 am     Reply with quote

Damn... Spend half a day working on that...

thx for the clarification but I'm confused on what to do

Should I:

1.) include the rtctimer.c file into my main.c and use or call the functions needed?
2.) copy paste the contents of the functions that I want into the main.c?

sorry but I forgot most of my c programming T_T
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 03, 2011 4:02 pm     Reply with quote

Quote:
1.) include the rtctimer.c file into my main.c and use or call the functions needed?

Yes, that's the normal way to use a driver file. You include it with an
#include statement. That's how CCS does it in this example file:
Quote:

c:\program files\picc\examples\ex_rtctimer.c
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