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???
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???