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.

uart operand not defined on pic16f877a

Status
Not open for further replies.

trojanL

Newbie level 3
Joined
Dec 12, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,378
hi, can anyone solve my pic programming error here, i am new in programming language. i hope there someone could help me....;-)
this is my code,i write it in c basic and want to program it in pic16f877a interfaced with gsm phone and max 232 as the signal converter. i get this error>> Error [500] ; 0. undefined symbols:
_DataRdyUART1(fyp2.obj) _getsUART1(fyp2.obj) _WriteUART1(fyp2.obj)
i know that it was because of the uart header i use didnt define those things, then i came with conclusion maybe i use wrong uart operand for the pic.. and my program also have many warning, it is OK to ignore the warning or i should take caution to it?


#include <pic.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include "uart.h"

#use delay(clock=20000000)
#use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,errors)

#define __CONFIG & _BODEN_OFF & _CP_OFF & _DEBUG_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _HS_OSC

//TXSTA: 0x24;
//RCSTA: 0x96;

void sms_read();
void send();
void main();
void init();

char low;
unsigned char output[25];
unsigned char reply[25];
unsigned char temp[25];
const char msg1 = "high traffic";
const char msg2 = "medium traffic";
const char msg3 = "low traffic";
const char msg4 = "wrong instruction";
const char data1 = "Traffic condition";

void main()
{
WriteUART1("AT\n\r");
_delay(500);
WriteUART1("AT+CMGS='ME'");
_delay(500);
WriteUART1("AT+CMGF=1\n\r");
_delay(500);
sms_read();
}


void sms_read()
{

WriteUART1("AT+CMGR=1\n\r");
_delay(500);
while (1) {
if (DataRdyUART1() == 1) // if data is received
{
*(temp)=getsUART1();
if (strcmp(temp,data1)==0)
{
void send();
{
low = 0;
PORTE = 1;
int i;

WriteUART1("AT+CMGS=");
WriteUART1(0x22);
WriteUART1("+0149521517");
WriteUART1(0x22);
WriteUART1("\n\r");
_delay(500); // sends back text

if (RE0 = low);
{
strcpy(*(reply),msg1);
}

if (RE1 = low);
{
strcpy(*(reply),msg2);
}

if (RE2 = low);
{
strcpy(*(reply),msg3);
}
WriteUART1(reply[25]);
WriteUART1(26);// send ctrl + Z
}
}

else
{
WriteUART1("AT+CMGS=");
WriteUART1(0x22);
WriteUART1("+0149521517");
WriteUART1(0x22);
WriteUART1("\n\r");
_delay(500); // sends back text
strcpy(*(reply),msg4);
WriteUART1(reply[25]);
WriteUART1(26);// send ctrl + Z
}
}
else
{
sms_read();
}


}
}
index.php
 

Well warnings are pretty useful when it comes to efficient programming, it tells you about unused variables and other things which not necessary. but still with warnings your project can run you may ignore those when you are developing but by the end when you are finishing you should remove these warnings...
now for your problem please tell which compiler are you using if CCS compiler then you can use simple printf command to send data to UART why are you using uart.h
undefined symbols means that it can can't see those functions make sure the header file is included correctly i.e it is present in the project path....
 

sory for the late reply, im trying to use ur idea by using printf but i keep having error about undefine printf and putchar....
then i write another program, but in isis simulation, the program only transmit on tx data the character "y" 3times and transmit infinity charater p in port RC2.

can u plz check my code, im realy desparate as my date line is near,,,

/*this programming written by Zeckrey jikurun 4th year ee studentd */

#include <pic.h>
#include <string.h>
//======config=======
__CONFIG (0x3F32);
__EEPROM_DATA(0, 1, 2, 3, 4, 5, 6, 7);
//================define io==================

#define lcd PORTB
#define RS RB4
#define E RB6
#define _XTAL_FREQ 20000000
#define data_data()

//================function prototype========
void uart_send(unsigned char data);
unsigned char uart_rec(void);
void long_delay(unsigned short i);



//================function prototype==============
void e_pulse(void);
void delay(unsigned short i);
void send_char(unsigned char data);
void send_config(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void dis_num(unsigned long data);
void increment(unsigned long data);


//==================main program==================

void main (void)
{

TRISB=0b00000000; //define port B to be output
PORTB=0;
TRISE=0b111; //define port E to be input
PORTE=1;
TXSTA=0b00100110;
RCSTA=0b10110110;
TRISC=0b10000000;
PORTC=0;

send_config(0b00000001); //clear display at lcd
send_config(0b00000010); //Lcd Return to home
send_config(0b00000110); //entry mode-cursor increase 1
send_config(0b00001100); //diplay on, cursor off and cursor blink off
send_config(0b00111000); //function set

char uart_data1[]="AT"; //check for the gsm respone
char uart_data2[]="AT+CPMS=\"ME\""; //restore the message in prefer location
char uart_data3[]="AT+CMGR=1"; //read in location 1
char uart_data6[]="AT+IPR=9600";
char uart_data7[]="AT+CMGF=1"; //select in text mode
char uart_data8[]="AT+CMGD=1"; //delete msg in location 1

//+0149521517\invalid input\x1A ; //send msg
//+0149521517\"high\x1A";
//+0149521517\"med\x1A";
//+0149521517\"low\x1A";

char uart_data5[]="AT+CMGW=";
char uart_data9[]="AT+CMGW=";
char uart_data10[]="AT+CMGW=";
char uart_data11[]="AT+CMGW=";

char uartx[]="invalid input\x1A";
char uart0[]="high\x1A";
char uart1[]="med\x1A";
char uart2[]="low\x1A";


unsigned char data[25];
unsigned char dat1[10];
unsigned char dat2[80];
unsigned char msg[50];
unsigned short i, j, x;
int putchar (int c);
int printf (const char * fmt, ...);

//unsigned char address = 0;
//unsigned char address = 1;
//unsigned char address = 2;
//unsigned char address = 3;



/*TRISB = 0;
TRISC6 = 0;
TRISC7 = 1;
PORTB = 0;
PORTC = 0;
SPBRG = 129;
BRGH = 1;
TXEN = 1;
TX9 = 0;
RX9 = 0;
SPEN = 1;
CREN = 1;*/

// eeprom write
eeprom_write(0, uart_data5);
eeprom_write(1, uart_data9);
eeprom_write(2, uart_data10);
eeprom_write(3, uart_data11);




while (1){

//DUMMY FOR lcd TO SEE OVERALL PROCESS
lcd_clr();
lcd_goto(0);

send_char('r');
send_char('E');
send_char('a');
send_char('d');
send_char('y');

__delay_ms(1000);


//AT+IPR=9600 set boud rate 2 9600

for(i=0; i<=10; i++)
{
uart_send(uart_data6);
}

uart_send(13);
__delay_ms(2000);



//AT+CMGF=1

for(i=0; i<=8; i++)
{
uart_send(uart_data7);

}

uart_send(13);
__delay_ms(2000);

//AT+CPMS="ME"
for(i=0; i<=11; i++)
{
uart_send(uart_data2);

}

uart_send(13);
__delay_ms(2000);


//AT

for(i=0; i<=1; i++)
{
uart_send(uart_data1);

}

uart_send(0X0D);
__delay_ms(2000);


lcd_clr();
lcd_goto(0);



CREN=0;
CREN=1;


if(OERR==0)
{ for(i=0; i<=80; i++)
dat2=uart_rec();
send_char(dat2);
__delay_ms(2000);
}

else
send_char('W');
send_char('a'); //dat2[1]=uart_rec();
send_char('i'); //send_char(dat2[1]);
send_char('t');
dat2[1]=uart_rec();
send_char(dat2[1]);
__delay_ms(2000);


}

void get_phone(void); //TO get the phone no
{
for(i=21; i<=32; i++)
for(j=0; j<=10; j++)
dat1[j]=dat2;

send_char('P');
send_char('H');
send_char('O');
send_char('N');
send_char('E');
send_char(' ');
send_char('N');
send_char('O');
send_char(dat1[j]);
__delay_ms(2000);

}

void check_msg(void);
{msg[43] = eeprom_read(0);

if (dat2[55]==0x54)
{
send_char('T');
__delay_ms(100);
}
else
{
for(i=0; i<=43; i++);
{
uart_send(msg);
}
}

if (dat2[56]==0x52)
{
send_char('R');
__delay_ms(100);
}
else
{
for(i=0; i<=43; i++);
{
uart_send(msg);
}
}

if (dat2[57]==0x41)
{
send_char('A');
__delay_ms(100);
}
else
{
for(i=0; i<=43; i++);
{
uart_send(msg);
}
}

for (i=58; i<=59; i++)
if (dat2==0x46)
{
send_char('F');
__delay_ms(100);
}
else
{
for(i=0; i<=43; i++);
{
uart_send(msg);
}
}

if (dat2[60]==0x49)
{
send_char('I');
__delay_ms(100);
}
else
{
for(i=0; i<=43; i++);
{
uart_send(msg);
}
}

if (dat2[61]==0x43)
{
send_char('C');
__delay_ms(100);
void logic0(void);
{
msg[10] = eeprom_read(1);
if (RE0==1)
{ for(i=0; i<=10; i++)
uart_send(msg);
uart_send('"');
for(j=0; j<=10; j++)
uart_send(dat1[j]);
uart_send('"');
for(x=0; x<=8; x++)
uart_send(uart0[x]);
}
else
{msg[10] = eeprom_read(2);
if (RE1==1)
{ for(i=0; i<=10; i++)
uart_send(msg);
uart_send('"');
for(j=0; j<=10; j++)
uart_send(dat1[j]);
uart_send('"');
for(x=0; x<=8; x++)
uart_send(uart1[x]);
}
else
{msg[10] = eeprom_read(3);
if (RE2==1)
{ for(i=0; i<=10; i++)
uart_send(msg);
uart_send('"');
for(j=0; j<=10; j++)
uart_send(dat1[j]);
uart_send('"');
for(x=0; x<=8; x++)
uart_send(uart2[x]);
}
else
{
main();
}
}
}


}
}
else
{

for(i=0; i<=43; i++);
{
uart_send(msg);
}
}

}





}

//==================subroutine LCD setting ==========================

void uart_send(unsigned char data)
{
while(TXIF==0); //only send the new data after
TXREG=data; //the previous data finish sent
}

unsigned char uart_rec(void) //receive uart value
{
unsigned char rec_data;
while(RCIF==0); //wait for data
rec_data=RCREG;
return rec_data; //return the received data
}



void send_config(unsigned char data)
{
RS=0;
lcd=data;
delay(500);
e_pulse();
}

void e_pulse(void)
{
E=1;
delay(500);
E=0;
delay(500);
}

void send_char(unsigned char data)
{
RS=1;
lcd=data;
delay(500);
e_pulse();
}


void lcd_goto(unsigned char data)
{
if(data<16)
{
send_config(0x80+data);
}
else
{
data=data-20;
send_config(0xc0+data);
}
}


void lcd_clr(void)
{
RS=0;
send_config(0x01);
delay(600);
}


void dis_num(unsigned long data)
{
unsigned char hundred_thousand;
unsigned char ten_thousand;
unsigned char thousand;
unsigned char hundred;
unsigned char tenth;

hundred_thousand = data/100000;
data = data % 100000;
ten_thousand = data/10000;
data = data % 10000;
thousand = data / 1000;
data = data % 1000;
hundred = data / 100;
data = data % 100;
tenth = data / 10;
data = data % 10;

if(hundred_thousand>0)
{
send_char(hundred_thousand + 0x30); //0x30 added to become ASCII code
send_char(ten_thousand + 0x30);
send_char(thousand + 0x30);
send_char(hundred + 0x30);
send_char(tenth + 0x30);
send_char(data + 0x30);
}

else if(ten_thousand>0)
{
send_char(ten_thousand + 0x30); //0x30 added to become ASCII code
send_char(thousand + 0x30);
send_char(hundred + 0x30);
send_char(tenth + 0x30);
send_char(data + 0x30);
}
else if(thousand>0)
{
send_char(thousand + 0x30); //0x30 added to become ASCII code
send_char(hundred + 0x30);
send_char(tenth + 0x30);
send_char(data + 0x30);
}
else if(hundred>0)
{
send_char(hundred + 0x30); //0x30 added to become ASCII code
send_char(tenth + 0x30);
send_char(data + 0x30);
}
else if(tenth>0)
{
send_char(tenth + 0x30); //0x30 added to become ASCII code
send_char(data + 0x30);
}
else send_char(data + 0x30); //0x30 added to become ASCII code
}

void increment(unsigned long data)
{
unsigned short j;
for(j=10;j>0;j--)
{ lcd_goto(32);
data=data+1;
dis_num(data);
delay(10000);
}

}

//========================delay routine==========
void delay(unsigned short i)
{
for(;i>0;i--);
}
 

im using HI-TECH C Compiler for PIC10/12/16 MCUs (PRO Mode) V9.81..
sory for the late reply...
thanks in advandce..^^
 

Well i haven't use Hi-Tech C compiler rather i use CCS compiler which gives me simple printf command...

in the last code you have posted where are you setting the Serial configurations..?
I mean baud rate parity , start.stop bits etc...

have you simulated this code..?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top