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.

mplan ide v8.83 compiling error

Status
Not open for further replies.

chalani0088

Junior Member level 3
Junior Member level 3
Joined
Jun 19, 2012
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,562
mplab ide v8.83 compiling error

HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode) V9.83
Copyright (C) 2011 Microchip Technology Inc.
(1273) Omniscient Code Generation not available in Lite mode (warning)
Error [500] ; 0. undefined symbols:
_getche(sirial.obj) __scanf_buf_(sirial.obj)

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


i used sscanf command i my program and i get this error message ; can anybody help me out on this! i am using pic 16f877a controller and i want to convert the stored gps nmea data into float type or numeric! can anybody suggest something to solve the problem?
 
Last edited:

I would suggest posting, by using the code tags, or upload your code.

Typically routines which input or output data need to be explicitly instructed where to do so.

Often this is accomplished by writing a routine to handle the I/O.

Hi-Tech Compiler Manual:
3.13 Standard I/O Functions and Serial I/O
A number of the standard I/O functions are provided, specifically those functions intended to read
and write formatted text on standard output and input. A list of the available functions is in Table
3.12. More details of these functions can be found in Appendix A.
Before any characters can be written or read using these functions, the putch() and getch()
functions must be written. Other routines which may be required include getche() and kbhit().


Another issue which can be a source of error messages is the use of legacy headers with the newer versions of the compiler.

One possible solutions is the inclusion of the following at the start of the code:

#define _LEGACY_HEADERS




BigDog
 
I would suggest posting, by using the code tags, or upload your code.

Typically routines which input or output data need to be explicitly instructed where to do so.

Often this is accomplished by writing a routine to handle the I/O.

Hi-Tech Compiler Manual:



Another issue which can be a source of error messages is the use of legacy headers with the newer versions of the compiler.

One possible solutions is the inclusion of the following at the start of the code:






BigDog














how to manupulate gps nmea data to float type using pic16f877a


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include <htc.h>
 
#define RX_PIN TRISC7
#define TX_PIN TRISC6
#define _XTAL_FREQ 4000000
 
 
__CONFIG(1,XT & WDTDIS & LVPDIS);
 
/****** serial comms using USART to comm port ***************/
 
void serial_setup()
{
SYNC=0; //Asynchronous mode
BRGH=1; //High Speed
SPBRG=25; //9600 bps
SPEN=1; //Enable serial port
CREN=1; //Enable reception
SREN=0; //No effect
TXIE=0; //Desable interrupts
RCIE=0; //disable rx interrupts
TX9=0; //8-bit transmission
RX9=0;  //8-bit reception
TXEN=1; // Enable transmission
}
 
void putch(unsigned char byte) 
{
/* output one byte */
while(!TXIF)    /* set when register is empty */
continue;
TXREG = byte;
}
 
unsigned char getch() {
/* retrieve one byte */
while(!RCIF)    /* set when register is not empty */
continue;
return RCREG;   
}
 
 
 
unsigned char getch();
unsigned char longi_data[12];
unsigned char lati_data[12];
unsigned char data,value=0;
unsigned int i=0,pos;
 
float latitude;
 
void main(void){
RX_PIN = 1; 
TX_PIN = 0;
unsigned char input1;
unsigned char input2;
unsigned char input3;
serial_setup();
INTCON=0;   // purpose of disabling the interrupts.
 
 
 
 
while(1){
 
{
data=getch(); // Check the string '$GPGGA,'
if(data=='$')
{
data=getch();
if(data=='G')
{
data=getch();
if(data=='P');
{
data=getch();
if(data=='G');
{
data=getch();;
if(data=='G')
{
data=getch();
if(data=='A')
{
data=getch();
if(data==',')
{
data=getch();
while(data!=',')
 
data=getch();
 
for(i=0;data!='N';i++)
{   data=getch();
lati_data[i]=data; // Store the Latitude data
 
putch(data);
}
}    data=getch();
if(data==',')
{
for(i=0;data!='E';i++)
{
data=getch();
 
longi_data[i]=data; // Store the Longitude data
putch(data);
}
}
 
 
 
 
i=0;
 
while(i<11)
{
PORTB=lati_data[i]; // Print the Latitude data
 
i++;
}
 
i=0;
 
while(i<12)
{
PORTD=longi_data[i];     // Print the Longitude data
 
 
i++;
}
 
 
 
 
 
}
 
 
 
 
 
 
 
 
 
}
}
}
}
}
}
 
__delay_ms(10);
for(i=0;i<12;i++)
{
data=0;
lati_data[i]=0;
longi_data[i]=0;
}
}
 
 
}




am doing my final project on gps based warning system for fishermen, and i want to receive gps data into my controller and exctract only the longitudanal and latitudanal data, and then i have to compare it with my previously stored boundaries and make nececsary outputs by comaparing, In my program i could exctract only the longitudanal and latitudanal data , and stored them as character strings. This worked fine and i checked using pic simulator i gave the sentence $GPGGA,100156.000,2650.9416,N,07547.8441,E,1,08,1. 0,442.8,M,-42.5,M,,0000*71 to the hardware UART simulation interface and it correctly worked.I am using MPLAB IDE V8.83 and now i want to convert this character string in to numerics in order to compare with my boundaries. so i used sscanf command and it doesnt work well! and i want to know wheathr i need to insetr stdio.h header and the source code. can you please help me on this?

Thank you
 
Last edited by a moderator:

hi,
i found a way to get rid of my problem, i used a for loop and switch command to convert my characters in to integers, but again i faced a problem i.e. i couldnt store the decimal point inside my integer array. how to get rid of this problem?




Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
float long_arr[11];
 
for(i=0; i!=12;i++)
{
 
switch (lati_data[i])
{
 
case '0' :
long_arr[i]=0;
break;
case '1':
long_arr[i]=1;
break;
 
case '2':
long_arr[i]=2;
break;
 
case '3':
long_arr[i]=3;
break;
case '4':
long_arr[i]=4;
break;
 
case '5':
long_arr[i]=5;
break;
case '6':
long_arr[i]=6;
break;
 
case '7':
long_arr[i]=7;
break;
 
case '8':
long_arr[i]=8;
break;
 
case '9':
long_arr[i]=9;
break;
case '.' :
long_arr[i]=0;
break;
 
}
 
}

 
Last edited by a moderator:

The Hi-Tech C Compiler for the PIC10/12/16 does offer several routines which can convert an ASCII string to an integer, long or float:

Reference: HI-TECH C® for PIC10/12/16 User’s Guide, Section Library Functions, Page: 181-183


ATOF

Synopsis

#include <stdlib.h>
double atof (const char * s)

Description

The atof() function scans the character string passed to it, skipping leading blanks. It then
converts an ASCII representation of a number to a double. The number may be in decimal, normal
floating point or scientific notation.
Example

#include <stdlib.h>
#include <stdio.h>

void
main (void)
{
char buf[80];
double i;
gets(buf);
i = atof(buf);
printf(" %s: converted to %f\n" buf, i);
}

See Also
atoi(), atol(), strtod()

Return Value

A double precision floating-point number. If no number is found in the string, 0.0 will be
returned.


ATOI

Synopsis

#include <stdlib.h>
int atoi (const char * s)

Description

The atoi() function scans the character string passed to it, skipping leading blanks and reading an
optional sign. It then converts an ASCII representation of a decimal number to an integer.
Example

#include <stdlib.h>
#include <stdio.h>

void
main (void)
{
char buf[80];
int i;
gets(buf);
i = atoi(buf);
printf(" %s: converted to %d\n" buf, i);
}

See Also

xtoi(), atof(), atol()

Return Value
A signed integer. If no number is found in the string, 0 will be returned.

You could also use the strtok() routine to parse the GPGGA sentence into its appropriate tokens.

STRTOK

Synopsis

#include <string.h>
char * strtok (char * s1, const char * s2)

Description
A number of calls to strtok() breaks the string s1 (which consists of a sequence of zero or more
text tokens separated by one or more characters from the separator string s2) into its separate
tokens.
The first call must have the string s1. This call returns a to the first character of the first
token, or NULL if no tokens were found. The inter-token separator character is overwrit- ten by a
null character, which terminates the current token.
For subsequent calls to strtok(), s1 should be set to a NULL . These calls start searching from the
end of the last token found, and again return a to the first character of the next token, or NULL
if no further tokens were found.
Example

#include <stdio.h>
#include <string.h>
void
main (void)
{
char * ptr;
char buf[] = " is a string of words." char * sep_tok = ",?! "
ptr = strtok(buf, sep_tok);
while(ptr != NULL) {
printf("s\n" ptr);
ptr = strtok(NULL, sep_tok);
}
}

Return Value

Returns a to the first character of a token, or a null if no token was found.
Note

The separator string s2 may be different from call to call.

The resulting tokens can be convert into their appropriate numerical values and stored in a structure type.

BigDog
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top