pic 18f6527 serial communication

Status
Not open for further replies.

manj

Newbie level 5
Joined
Dec 7, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
hi
I am working on project for interfacing gsm modem with pic.for sending the at commands i used routine for transmission through uart.
write_string("AT\r\n")
for this I wrote the fun as-
void write_string(unsigned char *str)
{
while(*str!='\0')
{
TXSTAbits.TXEN=1;
TXREG=*str;
while(!TXSTAbits.TRMT);
str++;
TXSTAbits.TXEN=0;
}
}
but if I passed string as written above m getting garbage value and if i passed array like unsigned char a[]="AT\r\n"
then m getting exactly what i want i.e. AT\r\n
so i wrote 2 different routines for this still i got garbage value for the direct passing of string. why is this so because same routine I have used it for 8051 and haven't face any problem???
 

You have to make TRMT zero after the while(!TXSTAbits.TRMT) loop. Try making *str as global variable and assing it some default value like
unsigned char *str = " ";. See if that works.
 
Last edited:

hi
I have tried as you said but still same for sending string directly m getting garbage value. and I was getting warning also that suspicious pointer conversion.??? I am not getting why is this so because same logic I have applied for 8051 controller and it works but for pic m getting garbage value and also warning...
 

sorry for late reply I have tried by that way also still the same.so now m using printf statement but still not getting whats the problem with writing string directly using write_string fun.?
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…