This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem in receiving the text serially from port p3.o of At89c51 using pointer.

Hi! i am new to this forum. But still i am sure that this is the place where i could solve the problem regarding my code written in keil c.

Actually, I am working with the voice controlled project. I am sending the speech that has been converted to text through Usb to rs232c cable to p3.0 port of Atmel AT89c51 microcontroller. Now, I am controlling the microcontroller using the keil c. So, I need to receive the text serially using pointers or any other mechanism and the extracted word shoud be compared to either of the commands like right, left,stop,back and provide the appropriate logigic values to motor driving circuit to control the motor. So i have worked with this keil for long time but still i am not getting the respose from the microcontroller side toward the motor driving circuit.

So please help me in moving my project forward.
cheers.

Parents
  • My code for receiving the text like move and back sent from the pc is as below.
    Why my code can't receive the text serially. Can anyone correct my code.

    #include <reg51.h>
    #include <stdio.h>
    #include <math.h>
    #include <string.h> /* ports of l293d for making the motor in forward and backward direction. sbit la=P2^0; sbit lb=P2^1; sbit lc=P2^3; sbit ld=P2^5; sbit le=P2^6; sbit lf=P2^7; void serial(); void delay(); void moves(); void backs(); void lefts(); void rights(); char *rec,c; char *s[1]={"move"}; char *t[1]={"back"}; void main() { SCON = 0x50; /* Set Serial IO to receive and normal mode */ TMOD = 0x20;/*mode 1 and autoreload*/ TCON = 0x40; TH1 = 0xFD;/* value to set 9600 baud rate */ TR1 = 1;/* start timer to Receive */ IE = 0x90; EA = 1; ES = 1; RI=0; while(1) { serial(); if(*rec==*s) { la=1; lb=0; lc=1; ld=1; le=0; lf=1; delay(); } if(*rec==*t); {la=0; lb=1; lc=1; ld=1; le=1; lf=0; delay(); } }} void serial() interrupt 4 {while(1) { while(RI!=1) {} c=SBUF; if(c!=0) { *rec=c; rec++; c=0; RI=0; break; } else return; }}

    void delay()
    { int i,j;
    for(i=0;i<1000;i++);
    for(j=0;j<1000;j++);
    }

Reply
  • My code for receiving the text like move and back sent from the pc is as below.
    Why my code can't receive the text serially. Can anyone correct my code.

    #include <reg51.h>
    #include <stdio.h>
    #include <math.h>
    #include <string.h> /* ports of l293d for making the motor in forward and backward direction. sbit la=P2^0; sbit lb=P2^1; sbit lc=P2^3; sbit ld=P2^5; sbit le=P2^6; sbit lf=P2^7; void serial(); void delay(); void moves(); void backs(); void lefts(); void rights(); char *rec,c; char *s[1]={"move"}; char *t[1]={"back"}; void main() { SCON = 0x50; /* Set Serial IO to receive and normal mode */ TMOD = 0x20;/*mode 1 and autoreload*/ TCON = 0x40; TH1 = 0xFD;/* value to set 9600 baud rate */ TR1 = 1;/* start timer to Receive */ IE = 0x90; EA = 1; ES = 1; RI=0; while(1) { serial(); if(*rec==*s) { la=1; lb=0; lc=1; ld=1; le=0; lf=1; delay(); } if(*rec==*t); {la=0; lb=1; lc=1; ld=1; le=1; lf=0; delay(); } }} void serial() interrupt 4 {while(1) { while(RI!=1) {} c=SBUF; if(c!=0) { *rec=c; rec++; c=0; RI=0; break; } else return; }}

    void delay()
    { int i,j;
    for(i=0;i<1000;i++);
    for(j=0;j<1000;j++);
    }

Children