engshahrul
Banned

Hi, I'm doing UART Software code. That's I wan't transmit and receive using normal pin.
Here my code, using Hi-Tech compiler. Baudrate 9600.
I want read data starts with '$' and ending with '.' . Here my function for transmit and receive
With this code, I only can send 6 byte from hyperterminal and vb without error.
Ex, I send $1234. The LCD display 1234
If send more than that, PIC dosn't recognize the '.' character anymore.
Would anyone comment something, compare UART Software on CCS or Micro C. Or anyone have idea to improve this.
Here my code, using Hi-Tech compiler. Baudrate 9600.
Code:
for(;;){
i=0;
for(;;){
data[i]=uart_soft_receive();
if(i==0){if(data[i]=='$') i++;}
else if(data[i]!='.') i++;
else break;}
lcd_goto(0x40);
i=1;
while(data[i]!='.') lcd_write(data[i++]);
while(i<17){
lcd_write(' ');
i++;}
}
void uart_soft_transmit(char data)
{int i,j;
TX1=0;
for(j=0;j<baud_delay;j++) continue;
for(i=0;i<=7;i++){
TX1=data;
data=data>>1;
for(j=0;j<baud_delay;j++) continue;}
TX1=1;
for(j=0;j<baud_delay;j++) continue;
}
unsigned char uart_soft_receive(void)
{unsigned char data=0;
int i,j;
while(RX1==1) continue;
for(j=0;j<baud_delay;j++) continue;
for(i=0;i<=7;i++){
data=(data>>1)|(128*RX1);
for(j=0;j<baud_delay;j++) continue;}
return data;}
void uart_soft_string(const char *s)
{
while(*s)
uart_soft_transmit(*s++);
}
With this code, I only can send 6 byte from hyperterminal and vb without error.
Ex, I send $1234. The LCD display 1234
If send more than that, PIC dosn't recognize the '.' character anymore.
Would anyone comment something, compare UART Software on CCS or Micro C. Or anyone have idea to improve this.