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

How recieve string into controller

Hi everybody!

I work with Keil C251 uVision2.
in my programm i want to recieve string into controller. i have an array of characters incom[20], which i use as a buffer for recieving string. i recieve current byte into variable bufIn and then replace it into my array:

 1.  	strcat(incom, bufIn);

or
 2.     incom[i] = bufIn;
	i++;
in 2 cases before (1) & (2) i test with my routine Print(unsigned char) and can see that every next byte is recieved into bufIn variable, and after (1) & (2) i can see that byte is stored into the next byte of incom[] array.
But after recieving the whole string while testing array:
for(i = 0; i < 20; i++)
     Print(incom[i]);
i can see the empty string with only the last recieved byte on the last place, for example: " a".
If anybody can help me to recieve the whole string?
And else. Why i can't create any array of characters more than 20 symbols?
Thaks.
Gennady.

Parents
  • Your code not full...
    I still don't understand it.
    No hardware initialization sequence.
    (serial port, interrupts, timers)

    No sense to comment all of your code, just at first look:

    - you must clear RI manually

     if (RI)
     {	
       RI = 0; // !!!
    

    - you must process TI serial interrupt
    during PrntTo() or disable serial interrupts.
    (don't mix interrupt-driven
    serial input with
    "while(!TI);" sending method
    You need anything like:
    void port_io(void) interrupt 4 using 2 
    {  
     if( TI ) {
         TI = 0;
        // etc
     }
     if (RI) {
         RI = 0;
        // etc
     }
    }
    

    You can easy locate all of your problems via step-by-step debugging
    after Stop on Breakpoint in line

     void port_io(void) interrupt 4 using 2 
    


    Read "Application Note"
    http://www.keil.com/support/docs/1653.htm

Reply
  • Your code not full...
    I still don't understand it.
    No hardware initialization sequence.
    (serial port, interrupts, timers)

    No sense to comment all of your code, just at first look:

    - you must clear RI manually

     if (RI)
     {	
       RI = 0; // !!!
    

    - you must process TI serial interrupt
    during PrntTo() or disable serial interrupts.
    (don't mix interrupt-driven
    serial input with
    "while(!TI);" sending method
    You need anything like:
    void port_io(void) interrupt 4 using 2 
    {  
     if( TI ) {
         TI = 0;
        // etc
     }
     if (RI) {
         RI = 0;
        // etc
     }
    }
    

    You can easy locate all of your problems via step-by-step debugging
    after Stop on Breakpoint in line

     void port_io(void) interrupt 4 using 2 
    


    Read "Application Note"
    http://www.keil.com/support/docs/1653.htm

Children
No data