0
\$\begingroup\$

Can I use MCU's internal oscillator when communicating with GPS and cellular modules? I want to avoid connecting external crystals for the MCU since they generate noise, extra components, extra costs, and on top of that require PCB design constrains and cautions. My MCU is stm32L4

\$\endgroup\$
  • 1
    \$\begingroup\$ What do you mean, "communicating" with GPS? You can recieve GPS signals, but you need a dedicated GPS module for that. If you have that, the precision of the MCU clock is not relevant any more. \$\endgroup\$ – jusaca Dec 20 '18 at 15:13
  • 1
    \$\begingroup\$ Communicating over the UART should be fine off internal oscillator. Unless you're trying to do something like very precise GPS time sync. \$\endgroup\$ – pjc50 Dec 20 '18 at 15:25
  • 1
    \$\begingroup\$ gps uarts are generally slow, and can often be kept slow so that your internal oscillator should work fine. \$\endgroup\$ – old_timer Dec 20 '18 at 15:36
  • 1
    \$\begingroup\$ if you wanted to say use 115200 if you can find a device that even does that and if your chips uart is 16x oversampled that is 1.8mhz if you are running at 2mhz your accuracy may be pretty bad and not work, but if you run at 16 or 32 or whatever mhz you could even do 115200 well enough. a gps module at 4800 or 9600 times 16x should be clean enough. and some peripherals have an 8x oversample mode giving you more relief. But all of this is covered in the st documentation, just read it please. \$\endgroup\$ – old_timer Dec 20 '18 at 15:39
2
\$\begingroup\$

Asynchronous serial communications places demands on the accuracy of the clock. Some internal calibrated RC oscillators are acceptable, some are not, and some are okay over a limited temperature/Vcc range and/or if you don't have additional errors due to divider resolution (typically at higher speeds).

The receiving party starts timing the data based on when it detects a starting edge. That detection will be degraded a bit if the cables are long and by the number of times it samples within a given bit. Since the framing typically takes place on a per-byte basis, the error accumulates within the byte plus start bit, stop bit partity etc. which is typically about 10 bits per byte. So a 5% error means the receiver is looking at the data 1/2 bit off, which is right at the edge if everything else, including the receiver clock frequency is perfect.

If the other party is using a crystal controlled clock, a worst-case error of ~4% is probably (barely) acceptable. Usually 2% is used as a limit, if you don't have control of the other side.

An MCU with a 1% worst-case initial error (large print number) may have unacceptable or barely acceptable accuracy when all factors such as voltage coefficient and temperature coefficient are considered. For example, a typical spec from a "midrange" Microchip part

enter image description here

If your only need for serial communication is in an office/shop environment for configuration or diagnostics, the above is more than good enough for communications with a PC that is guaranteed to have a proper crystal controlled clock. If you expect it to work in a car, under all conditions, it's not guaranteed to be good enough.

If that is your only requirement for an accurate clock, I would suggest considering a ceramic resonator. It's not necessarily cheaper, but results in a lower parts count and is more rugged compared to a crystal oscillator and is typically more than good enough (0.5% is a typical spec) in accuracy for asynchronous serial communications.

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

Yes you can run with the internal oscilator, but you may not want to do all the work to make it happen. Depending on the exact STM32L4 part, you read the datasheet and take a look at the internal oscillator frequency tolerance, taking into account things like initial tolerance at given supply voltage and temperature and then the tolerance at the range of your supply voltages and temperatures. If it is out of tolerance for UART communications requirements (found in reference manual) then you need automatic calibration to stay within the tolerance. If you want to avoid all this, just put the crystal or oscillator there. Also note that the baud rate has no effect on this, only the tolerance.

\$\endgroup\$

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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