I'm not sure what wrong is it, I spend like a couple of days for it, but couldn't find an anwer, somebpdy please help me,
The problem is almost certainly a mistake or misunderstanding in the code or wiring you've used. But you have shown us only tiny fragments of code and we can't see how you actually connected the hardware. How is anyone supposed to know what was done incorrectly by only blind guessing?
A DUE has 5 UART: Serial, Serial1, Serial2, Serial3 and a Serial4 by adding 3 lines of code. You can test your serial connections with this example sketch on a single DUE board:
/**********************************************************************/
/****** Hook jumpers between RX1 and A11, and TX1 and pin 52 *******/
/**********************************************************************/
// Use the Arduino core to set-up the unused USART2 on Serial4
RingBuffer rx_buffer5;
RingBuffer tx_buffer5;
USARTClass Serial4(USART2, USART2_IRQn, ID_USART2, &rx_buffer5, &tx_buffer5);
void USART2_Handler(void) // Interrupt handler for UART2
{
Serial4.IrqHandler(); // In turn calls on the Serial4 interrupt handler
}
char c = 0;
void setup() {
PIO_Configure(PIOB, PIO_PERIPH_A, PIO_PB20A_TXD2 /* | PIO_PB21A_RXD2*/, PIO_DEFAULT);
Serial.begin(250000);
Serial1.begin(5000000);
Serial4.begin(5000000);
Serial4.print("Hello");
}
void loop() {
String s;
s = "";
while (Serial1.available() > 0) {
c = Serial1.read();
s += c;
}
if (s.length() > 0) {
Serial.println(s);
Serial4.print(s);
}
delay(1000);
}