Primero intenté mandar un unico dato y me lo devolvia correctamente, ahora intentamos mandar 3 datos distintos y no manda (o recibe bien).
Adjunto el codigo VB
Código
Private Sub Command1_Click() If MSComm1.PortOpen = True And Text7.Text = 3 Then MSComm1.Output = Text1.Text Text7.Text = Text7.Text - 1 End If If MSComm1.PortOpen = True And Text7.Text = 2 Then MSComm1.Output = Text3.Text Text7.Text = Text7.Text - 1 End If If MSComm1.PortOpen = True And Text7.Text = 1 Then MSComm1.Output = Text4.Text Text7.Text = Text7.Text - 1 End If End Sub Private Sub Command2_Click() MSComm1.PortOpen = False End End Sub Private Sub Command3_Click() If MSComm1.PortOpen = True And Text8.Text = 3 Then Text2.Text = MSComm1.Input Text8.Text = Text8.Text - 1 End If If MSComm1.PortOpen = True And Text8.Text = 2 Then Text5.Text = MSComm1.Input Text8.Text = Text8.Text - 1 End If If MSComm1.PortOpen = True And Text8.Text = 1 Then Text6.Text = MSComm1.Input Text8.Text = Text8.Text - 1 End If End Sub Private Sub Command4_Click() If MSComm1.PortOpen = True Then MSComm1.Output = Text7.Text End If End Sub Private Sub Command5_Click() If MSComm1.PortOpen = True Then Text8.Text = MSComm1.Input End If End Sub Private Sub Form_Load() If MSComm1.PortOpen = True Then Command1.Enabled = False End If If MSComm1.PortOpen = False Then MSComm1.PortOpen = True Shape1.FillColor = &HFF00& End If End Sub
Codigo C del uC
Código
void retardo (unsigned int n) { unsigned int i,j; for (i=0;i<n;i++) { for(j=0;j<0xFFFF;j++) {} } } void main (void) { SCON = 0x50; /* uart in mode 1 (8 bit), REN=1 */ TMOD = TMOD | 0x20 ; /* Timer 1 in mode 2 */ TH1 = 0xFD; /* 9600 Bds at 11.059MHz */ TL1 = 0xFD; /* 9600 Bds at 11.059MHz */ ES = 1; /* Enable serial interrupt */ EA = 1; /* Enable global interrupt */ TR1 = 1; /* Timer 1 run */ while(1); /* endless */ } /** * FUNCTION_PURPOSE: serial interrupt, echo received data. * FUNCTION_INPUTS: P3.0(RXD) serial input * FUNCTION_OUTPUTS: P3.1(TXD) serial output */ void serial_IT(void) interrupt 4 { if (RI==1 & count==0) { RI = 0; count = SBUF; SBUF = count; i=0; retardo(1); } if (RI==1 & count !=0) { if (i==0){ RI = 0; i++; uart_data1 = SBUF; SBUF = uart_data1; retardo(1); } if (i==1){ RI = 0; i++; uart_data2 = SBUF; SBUF = uart_data2; retardo(1); } if (i==3) { RI = 0; i++; uart_data3 = SBUF; SBUF = uart_data3; retardo(1); count=0; } } else TI = 0; /* if emission occur */ }