View previous topic :: View next topic |
Author |
Message |
Ivalex
Joined: 03 Jun 2011 Posts: 2
|
Q> about function calling |
Posted: Fri Jun 03, 2011 2:00 am |
|
|
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
thank you in advance to those who would reply |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Fri Jun 03, 2011 2:17 am |
|
|
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
|
|
Posted: Fri Jun 03, 2011 3:04 am |
|
|
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
|
|
Posted: Fri Jun 03, 2011 4:02 pm |
|
|
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 |
|
|
|
|