1
\$\begingroup\$

I want to use this microcontroller - Mini58FDE (Product page) (Datasheet)

Clock parameters are mentioned as:

Clock Control

  • 4 to 24 MHz crystal oscillator

  • Internal 22.1184 MHz (±1% accuracy at 25℃, 5V)

My intent is to avoid usage of an external crystal oscillator. I want to know if I can do so without any worries. From what I have read online, an RC internal oscillator with tolerance less than 3% is good for UART. The microcontroller that I am planning to use mentions 1% at 25 degree C. The datasheet mentions the following relevant info on page 46:

This chip supports auto-trim function: the HIRC trim (22.1184 MHz internal RC oscillator), according to the accurate LXT (32.768 kHz crystal oscillator), automatically gets accurate HIRC output frequency, 1 % deviation within all temperature ranges. For instance, the system needs an accurate 22.1184 MHz clock. In such case, if users do not want to use 22.1184 MHz HXT as the system clock source, they need to solder 32.768 kHz crystal in system, and set FREQSEL (SYS_IRCTCTL[0] trim frequency selection) to “1”, and the auto-trim function will be enabled. Interrupt status bit FREQLOCK (SYS_IRCTISTS[0] HIRC frequency lock status) high indicates the HIRC output frequency is accurate within 1% deviation. To get better results, it is recommended to set both LOOPSEL (SYS_IRCTCTL[5:4] trim calculation loop) and RETRYCNT (SYS_IRCTCTL[7:6] trim value update limitation count) to “11”.

I have the following questions:

  1. Is this microcontroller good for UART without using any external crystal oscillator? I have performed bench test and it worked without any problems. I need to be sure whether this is good enough to be used in a commercial product that can be used in temperature range of 10 degree C to 60 degree C.

  2. Is there a relationship between UART baud rate and clock tolerance? Will using a low baud rate be more reliable? Is there any relation chart (or theory) between clock tolerance and max reliable UART baud rate?

\$\endgroup\$
2
  • \$\begingroup\$ "My intent is to avoid usage of an external crystal oscillator" To discipline the 22.1184 MHz internal RC clock, a crystal oscillator is required. Do you mean to avoid an external oscillator? or do you mean an external crystal?. You must use an external crystal in either case, but you may choose between an external oscillator, or the on-board LXT oscillator. Seems simpler to use the HXT with a high-frequency crystal to ensure frequency stability, but there are unrelated good reasons to use the internal high-speed RC master oscillator. \$\endgroup\$
    – glen_geek
    Nov 17, 2023 at 14:00
  • \$\begingroup\$ @glen_geek - i mean to avoid any external clock component. This is to save pcb space and money. \$\endgroup\$ Nov 18, 2023 at 4:29

2 Answers 2

1
\$\begingroup\$

By itself, the MCU internal oscillator has 2% tolerance over large operating temperature and voltage range.

And, under ideal conditions, the bit sampling can be half a bit off at the stop bit. In practice a bit less. Which for 10-bit frames means about 4% tolerance, and you have to allow one device to have +/- 0.25 bits of error.

Which means, in theory, 2% should work, unless the nominal baud rate cannot be reached with 0% error due to divisors.

And it also does not include any errors from slew rate or asymmetry of signals on physical interfaces such as RS-232 interface, which may skew the bits further.

So I would not recommend being up to 2% unless you are sure to which device you will be communicating with.

And it will also be possible to fine-tune the RC oscillator, and autobaud detection will reduce the error somewhat.

For your Q2:

2% max tolerance in internal oscillator means everything you use that clock for will have 2% tolerance. All baud rates and all timekeeping features included. 100 seconds may be 102 seconds if you measure time.

\$\endgroup\$
0
\$\begingroup\$

Is there a relationship between UART baud rate and clock tolerance?

Yes. The clock the MCU uses and its accuracy determine the baud rate. if the clock is not good enough for the baud rate you want to use, you will get random bad bits/ bad reads/ randomly bad bits sent.

Will using a low baud rate be more reliable?

Yes, by a lot. If you try to use a large Baud rate while your clock is not accurate enough you will get a larger percentage of errors. The lower Baud rate you use the more reliable it will be.

Is there any relation chart (or theory) between clock tolerance and max reliable UART baud rate?

I suggest you do the test by yourself. even if there is a theory behind that, there are practical limitations/tolerances all kind of stuff that could go bad, like impedance mismatch you might have on your PCB etc. My suggestion would be to start testing the Baud rate from low values and increase the Baud rate. Each time you increase it, echo some data for a couple of minutes from the PC to the MCU and see if the echoed data are good (So you test both transmission and reception). I mention you do that for a couple of minutes, because the crystal might shift while the MCU operates. This shift can take some seconds, sometimes minutes.

I see in the datasheet of your MCU there is a way to calibrate your clock by using an external clock, if I understand this correclty.

....that can be used in temperature range of 10 degree C to 60 degree C.

The datasheet mentions "1% accuracy at 250C, 5V", but when it mentions the calibration with the external oscillator, it also mentions that you can calibrate the internal clock based on the temperature up to 105oC, so you might want to do that calibration. The datasheet doesn't say anything else (how to do that calibration, if you can get rid of the external clock after calibration etc), so you should look that up or ask the manufacturer of that MCU.

Mini58DE clock calibration

Also, check if there is a way to measure the clock of the internal oscillator. In the MCU I use (atmega328p aka the arduino uno's MCU) I can set the Fuse's setting to output the internal clock's pulse to one of the MCU's pins and measure it. Along with that, I can trim the Clock of my MCU by changing a register's value of the MCU, to make it closer to the value I want it to be. (8Mhz for the internal Clock of my MCU in this case).
A real-life example with my MCU, would be to tell you that I measure my MCU's clock to be from ~7.990 to ~8.02 Mhz usually for the products I make. (I make these measurements with a multimeter, thats the digits I can see with that, might not be that accurate). And that is enough to increase my Baud rate to 1Million b/s. If I leave the Clock untrimmed it sometimes defaults to 7.5 or 8.3Mhz and that randomly makes the BAUD rate communication broken.

From the Atmega328p's datasheet I can also see the rate error depending on the Freq of the clock and the Baud rate:

Atmega329p baud rate freq clock

Note here: Negative error does not mean there's no chance of an error happening. It tells you that the clock is slower (or faster depending on how you look at it) from the desired baud rate. The optimal error is the one closer to 0, NOT close to the negative value(s).

\$\endgroup\$
6
  • 3
    \$\begingroup\$ All good except your second answer: Baud rate does not matter -- % error is the same % error at any frequency. Especially given that the nominal frequency is 22.1184 MHz, which gives standard baud rates with zero initial error. \$\endgroup\$
    – Dave Tweed
    Nov 17, 2023 at 13:09
  • \$\begingroup\$ @DaveTweed interestin. So 22.1184Mhz crystals use that specific frequency to have the same (or zero) error for all standard baud rates? \$\endgroup\$ Nov 17, 2023 at 13:21
  • \$\begingroup\$ @ChristianidisVasilis No matter what the clock frequency is. If clock has 2% tolerance, everything you derive from it has 2% tolerance, be it a baud rate of 9600 or 1Mbps. \$\endgroup\$
    – Justme
    Nov 17, 2023 at 14:04
  • \$\begingroup\$ @ChristianidisVasilis What is affected by baud rate is jitter; by dividing a clock down further you improve clock jitter. But jitter is not a significant issue for UART communications. \$\endgroup\$
    – Hearth
    Nov 17, 2023 at 14:12
  • \$\begingroup\$ @Justme I think that depends on the MCU, how it handles the counting/timing to send the next bit on the UART bus. For example if you check on my latest screenshot, the MCU I use, I configure the BAUD rate depending on the UBRRn register. I think that tThe MCU counts UBRRn until the register reaches that value and then the MCU outputs the next bit. Therefore the error changes if say for 230.4k the optimal Register value would be 2.66, I cant input that, so I just put 3, and there is the error. \$\endgroup\$ Nov 17, 2023 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.