Go Down

Topic: possible UART clock speeds of the Arduino Due (Read 1 time) previous topic - next topic

tito-t

May 02, 2018, 09:05 am Last Edit: May 02, 2018, 09:21 am by tito-t
which subset  of the following UART clock freqencies is supported by the Arduino Due?

230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000

I am not a technician (but an administration employee), but I may remind that also Arduino primarily has been designed for non-technicians and non-computer scientists.

Nonetheless, I looked in datasheets like
https://store.arduino.cc/arduino-due -> tech specs and/or
http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf  and/or
http://copperhilltech.com/blog/arduino-due-microcontroller-board-based-on-the-atmel-sam3x8e-arm-cortexm3-cpu/

but even there nothing is written about the supported clock rates (I read and searched closely, but found nothing).

So which of the above mentioned clock freqencies is supported by the Arduino Due, understandable for non-technicians?

ard_newbie

Sam3x datasheet:

Page 752:
34.5.1 Baud Rate Generator

Page 768:
UART_BRGR register




tito-t

#2
May 02, 2018, 09:43 am Last Edit: May 02, 2018, 09:55 am by tito-t
 
Sam3x datasheet:

Page 752:
34.5.1 Baud Rate Generator

Page 768:
UART_BRGR register
sorry, but I don't find a list of clock rates  there, but as also stated , I am no technician and may miss something.

ard_newbie

#3
May 02, 2018, 10:00 am Last Edit: May 02, 2018, 10:01 am by ard_newbie
With the UART peripheral, baud rate = Mck / (CD * 16)   with CD between 1 and 2^16. As an administration employee, you should be able to make divisions, shouldn't you ?, and you will observe that none of your baud rates will match because CD must be an integer.


Whereas, with USART peripherals, the divider can have a decimal part. With Serial1, Serial2, Serial3 AND Serial4 you can select successfully any of your baud rates. Make yourself a favor, buy a DUE (~$15 on aliexpress) and test with this sketch:



Code: [Select]
/**  Hook a jumper between RX1 and TX2, and another one between RX2 and TX1   **/

char c = 0;
void setup() {
 
  Serial.begin(250000);   // To see the result on Serial monitor
  
  Serial1.begin(5000000); // <******* select the same baud rate for Serial1 and Serial2
  Serial2.begin(5000000);

  Serial2.print("Hello");
}


void loop() {
  String s;
  s = "";

  while (Serial1.available() > 0) {
    c = Serial1.read();
    s += c;
  }
  if (s.length() > 0) {
    Serial.println(s);
    Serial2.print(s);
  }
  delay(1000);
}

tito-t

#4
May 02, 2018, 10:10 am Last Edit: May 02, 2018, 10:12 am by tito-t
ok, thanks, I did not understand this formula, and tbh, I also don't understand yet what your code example actually does.

But IIUC, on the other serial ports >=Serial1 every single baud rate of the above mentioned >=230400 is expected to work, just with Serial.begin(x) nothing of them (and perhaps also nothing very close to any of them?).

If so, then that's a pity, because I use Serial() via the USB port to the 2nd device.

ard_newbie


I didn't say that it can not work with Serial (UART), but there is a error percentage. 230400 works with Serial !

tito-t

ok, so 230400 is the absolute upper limit then, and for all other ones the error percentage is to big to Serial(), is that correct?

westfw


Quote
on the other serial ports >=Serial1 every single baud rate of the above mentioned >=230400 is expected to work, just with Serial.begin(x) nothing of them?
Um.  I don't think that the Arduino core code supports the fractional baud rate divisors needed for this on the USARTs; it only supports the same mechanisms used by the (dumber) UART.  The HARDWARE allows it...




Quote
If so, then that's a pity, because I use Serial() via the USB port to the 2nd device.
If you're going via the USB/Serial port, then you have additional limitations imposed by the USB/Serial chip (which is an AVR, on Due.)

tito-t

#8
May 03, 2018, 09:48 am Last Edit: May 03, 2018, 11:05 pm by tito-t
thank you for your hint, I'll try to determine that!
Are the essential USB/Serial chip specs the same as of the atmega328p?

update:
230.4k is supposed to work both for the Due and the AVR in the USB/Serial chip, right?
http://wormfood.net/avrbaudcalc.php?bitrate=115.2k%2C230.4k%2C250k%2C.5m%2C1m%2C2m&clock=16&databits=8

westfw

I read the orange highlighting there as "230.4k just barely, maybe works, sometimes."

tito-t

@westf:
so ard_newbie's statement is not valid? :-o
I didn't say that it can not work with Serial (UART), but there is a error percentage. 230400 works with Serial !

Go Up