Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error in using Hi-Tech C Compiler (MPLAB): Undefined symbol: _time

Status
Not open for further replies.

PersianMan

Newbie level 4
Joined
Mar 29, 2010
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,369
Dear friends,
I have a small problem with hi-tech programming. usually I use C18 for programming but this time I have to use Hi-Tech C for PIC16 series because the code already exist based on this compiler and I wanna add some lines to get current date and time from PC due to setting the RTC chip.

Let me simplify the code as following:

code listing: hi-tech_test.c
----------------------------------------
#include <htc.h>
#include <time.h>

void
main(void) {

time_t td;
//struct tm * tp;

time(&td);
//tp = localtime(&td); //convert time_t to tm as local time


}


Build outcome in MPLAB:
--------------------------------------
Build C:\Users\Rowshan\MyCodes\PCW\rs485-rs232\hi-tech_test for device 16F877A
Using driver C:\Program Files (x86)\HI-TECH Software\PICC\9.83\bin\picc.exe

Make: The target "C:\Users\Rowshan\MyCodes\PCW\rs485-rs232\time_date_test.p1" is out of date.
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.83\bin\picc.exe" --pass1 C:\Users\Rowshan\MyCodes\MPLAB\time_date_test.c -q --chip=16F877A -P --runtime=default,+clear,+init,-keep,+osccal,-download,-resetbits,-stackcall,+clib --opt=default,+asm,-debug,-speed,+space,9 --warn=0 -D__DEBUG=1 --double=24 --float=24 --addrqual=ignore --mode=lite -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.83\bin\picc.exe" -ohi-tech_test.cof -mhi-tech_test.map --summary=default,-psect,-class,+mem,-hex --output=default,-inhx032 time_date_test.p1 --chip=16F877A -P --runtime=default,+clear,+init,-keep,+osccal,-download,-resetbits,-stackcall,+clib --opt=default,+asm,-debug,-speed,+space,9 --warn=0 -D__DEBUG=1 --double=24 --float=24 --addrqual=ignore --mode=lite -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"

HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode) V9.83
Copyright (C) 2011 Microchip Technology Inc.
Licensed for evaluation purposes only.
This licence will expire on Wed, 11 Sep 2013.
Error [499] ; 0. undefined symbol:
_time(hi-tech_test.obj)

********** Build failed! **********


As you know about the error:
(499) undefined symbol: (Assembler, Linker)
The symbol following is undefined at link time. This could be due to spelling error, or
failure to link an appropriate module.

When I remove line "time(&td);", every thing is OK.
I checked also by other versions or compiler like 9.60 PRO or 9.65 Lite even by TIDE but still I face with this error.
I check this folder (C:\Program Files (x86)\HI-TECH Software\PICC\9.83\sources) and found out that there is not file for function time() in sources folder, maybe that's why it shows this error. I checked the folder of other versions, they didn't have this file as well.

Could any body help me to solve this problem?
 

Pressing F11 while in MPLAB will open the Hi-Tech C manual. If you search for the Time function, it will state that you need to write your own time() function since the PIC doesn't have an RTC.

Description
This function is not provided as it is dependant on the target system supplying the current
time. This function will be user implemented. When implemented, this function
should return the current time in seconds since 00:00:00 on Jan 1, 1970. If the argument
t is not equal to NULL, the same value is stored into the object pointed to by t.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top