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 while transmitting array through serial

if i send one character from 8051 board to hyperterminal its working. suppose if i send an array to hyperterminal its not working. can anybody suggest whats wrong with my code.

here is my sample code

#include<reg52.h>
void main()
{
char name;
unsigned int i;
char hmi[] = {'0','0','0','0','3','0','3','3'};

PCON |= 0x80;
TMOD = 0x20;
TH1 = 0xFD;
SCON = 0x50;
TR1 = 1;

while(1)
{
while(!RI);
RI = 0;
name = SBUF;

TI = 0;
SBUF = '#';
while(!TI);

for(i = 0; i < 8; i++)
{
TI = 0;
SBUF = hmi[i];
while(!TI);
}
i = 0;

TI = 0;
SBUF = '?';
while(!TI);
}
}
}

Parents
  • Other than the fact that you posted code without having followed the instructions to use 'pre' tags to preserve code formatting and that there's an extra closing brace, there is nothing particularly wrong with your code. If you could send a single byte, you should be able to send multiple bytes.

    Since you are sending bytes back-to-back, how about checking HyperTerminal's setting for stop bits. It has to be set to '1' or you'll have to add a bit-time delay between sending bytes.

Reply
  • Other than the fact that you posted code without having followed the instructions to use 'pre' tags to preserve code formatting and that there's an extra closing brace, there is nothing particularly wrong with your code. If you could send a single byte, you should be able to send multiple bytes.

    Since you are sending bytes back-to-back, how about checking HyperTerminal's setting for stop bits. It has to be set to '1' or you'll have to add a bit-time delay between sending bytes.

Children