subhash2505
Newbie level 4
- Joined
- Jun 22, 2011
- Messages
- 6
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,335
hi gyus
im doing my project in pic16f877 controller in that im facing the problem in my usart program, i have written one program in that if i run the program in microC compiler means im not getting any error but then i dumbed into the controller im not getting any response from the tx pin the controller, here a pasetd my program, i kindly request you that any one please help with the program....................................:-D:-D:-D:-D:-D
unsigned char i,k,j,l,m,n,in;
unsigned char init[4]="AT\r";
unsigned char mes[11]="AT+CMGF=1\r";
unsigned char num[22]="AT+CMGS=\"9790058470\"\r";
unsigned char dat1[25]="First text";
unsigned char dat2[25]="Second text";
unsigned char dat3[25]="Third text";
unsigned char dat4[25]="fourth text";
unsigned char end=0x1A;
void sendmsg1();
void sendmsg2(unsigned char array[]);
void delay();
void main()
{
ADCON1 = 0x82;
TRISB=0XFF;
PORTC = 0;
TRISC = 0XBE;
for(i=0;i<=0;i++)
{
switch(PORTB)
{
case (0x01):
{sendmsg1();
delay_ms(1000);
sendmsg2(dat1);
break;
}
case(0x02):
{sendmsg1();
delay_ms(1000);
sendmsg2(dat2);
break;
}
case(0x03):
{sendmsg1();
delay_ms(1000);
sendmsg2(dat3);
break;
}
case(0x02):
{sendmsg1();
delay();
sendmsg2(dat4);
break;
}
}
}
}
void sendmsg1()
{
usart_init(9600);
for(j=0;j<4;j++)
{
usart_write(init[j]); //Veryfing gsm modem
}
delay(); //30sec delays
usart_write(0x0A); //new line
for(l=0;l<11;l++)
{
usart_write(mes[l]); //setting the format
}
delay();
usart_write(0x0A);
for(m=0;m<22;m++)
{
usart_write(num[m]); //setting the number
}
delay();
usart_write(0x0A);
}
void sendmsg2(unsigned char array[])
{
for(n=0;n<=25;n++)
{
usart_write(array[n]); //Transmitting the message
}
usart_write(0x0A);
delay();
usart_write(end);
delay();
}
void delay() //30sec delay
{
unsigned char y;
for(y=0;y<30;y++)
{
Delay_ms(1000);
}
}
please kindly help me and im very thankful to you
im doing my project in pic16f877 controller in that im facing the problem in my usart program, i have written one program in that if i run the program in microC compiler means im not getting any error but then i dumbed into the controller im not getting any response from the tx pin the controller, here a pasetd my program, i kindly request you that any one please help with the program....................................:-D:-D:-D:-D:-D
unsigned char i,k,j,l,m,n,in;
unsigned char init[4]="AT\r";
unsigned char mes[11]="AT+CMGF=1\r";
unsigned char num[22]="AT+CMGS=\"9790058470\"\r";
unsigned char dat1[25]="First text";
unsigned char dat2[25]="Second text";
unsigned char dat3[25]="Third text";
unsigned char dat4[25]="fourth text";
unsigned char end=0x1A;
void sendmsg1();
void sendmsg2(unsigned char array[]);
void delay();
void main()
{
ADCON1 = 0x82;
TRISB=0XFF;
PORTC = 0;
TRISC = 0XBE;
for(i=0;i<=0;i++)
{
switch(PORTB)
{
case (0x01):
{sendmsg1();
delay_ms(1000);
sendmsg2(dat1);
break;
}
case(0x02):
{sendmsg1();
delay_ms(1000);
sendmsg2(dat2);
break;
}
case(0x03):
{sendmsg1();
delay_ms(1000);
sendmsg2(dat3);
break;
}
case(0x02):
{sendmsg1();
delay();
sendmsg2(dat4);
break;
}
}
}
}
void sendmsg1()
{
usart_init(9600);
for(j=0;j<4;j++)
{
usart_write(init[j]); //Veryfing gsm modem
}
delay(); //30sec delays
usart_write(0x0A); //new line
for(l=0;l<11;l++)
{
usart_write(mes[l]); //setting the format
}
delay();
usart_write(0x0A);
for(m=0;m<22;m++)
{
usart_write(num[m]); //setting the number
}
delay();
usart_write(0x0A);
}
void sendmsg2(unsigned char array[])
{
for(n=0;n<=25;n++)
{
usart_write(array[n]); //Transmitting the message
}
usart_write(0x0A);
delay();
usart_write(end);
delay();
}
void delay() //30sec delay
{
unsigned char y;
for(y=0;y<30;y++)
{
Delay_ms(1000);
}
}
please kindly help me and im very thankful to you