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

Problems with serial communication

I have implemented a new serial data transfer protocol in our 8051 system (80C552).

I tryed to write the received characters immediately back to the terminal with the following commands:

	ucrs232_buffer[ucrec_count] = S0BUF;
	S0BUF = ucrs232_buffer[ucrec_count];
This two command lines are performed in the ISR. I wrote 16 chars and got back 13 completly different ones.

If I send a message from the 80C51 to the terminal its correct! Also the command from the terminal is correct.

What can be the reason for this wrong reception?

Parents
  • Hello Vaclav,

    thank you for your answer! The baud rate is 9600. My OSC=15MHz -->9765bps. This is not so good but it worked with the old protocol, and i did not any changes at the interface settings.

    I use the external interrupt which occurs with app. 915Hz. I set this to priority level 0 and the serial interrupt to priority level 1 --> No changes at all.

    if(RI)
    {	
    if (ucrec_count >= 128)
       ucrec_count=0;
    
    //store data from S0BUF
    ucrs232_buffer[ucrec_count] = S0BUF;
    S0BUF = ucrs232_buffer[ucrec_count];
    
    //if char equals <EOT>(0x04), set brs232_rec
    if (ucrs232_buffer[ucrec_count]==0x04)
      brs232_rec =1;
    ucrec_count++;
    RI=0;			
    }
    return;
    
    Writing the chars back to S0BUF was just inserted for test. If I do not use this line, I get also a wrong message. In normal case I read the char which was transferd to my buffer and check if it is an <EOT> sign.

    Is it a problem that my receive buffer is in external memory?

Reply
  • Hello Vaclav,

    thank you for your answer! The baud rate is 9600. My OSC=15MHz -->9765bps. This is not so good but it worked with the old protocol, and i did not any changes at the interface settings.

    I use the external interrupt which occurs with app. 915Hz. I set this to priority level 0 and the serial interrupt to priority level 1 --> No changes at all.

    if(RI)
    {	
    if (ucrec_count >= 128)
       ucrec_count=0;
    
    //store data from S0BUF
    ucrs232_buffer[ucrec_count] = S0BUF;
    S0BUF = ucrs232_buffer[ucrec_count];
    
    //if char equals <EOT>(0x04), set brs232_rec
    if (ucrs232_buffer[ucrec_count]==0x04)
      brs232_rec =1;
    ucrec_count++;
    RI=0;			
    }
    return;
    
    Writing the chars back to S0BUF was just inserted for test. If I do not use this line, I get also a wrong message. In normal case I read the char which was transferd to my buffer and check if it is an <EOT> sign.

    Is it a problem that my receive buffer is in external memory?

Children