# MAX\_CLOCK\_ERROR vs. better xtal?

**URL:** <https://www.thethingsnetwork.org/forum/t/max-clock-error-vs-better-xtal/31245>\
**Category:** Hardware\
**Created:** [October 28, 2019, 11:39pm UTC](https://www.thethingsnetwork.org/forum/t/max-clock-error-vs-better-xtal/31245 "2019-10-28T23:39:53Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![bluejedi](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bluejedi/32/44639_2.png) [@bluejedi](https://www.thethingsnetwork.org/forum/u/bluejedi)\
**Post date:** [October 30, 2019, 12:27pm UTC](https://www.thethingsnetwork.org/forum/t/max-clock-error-vs-better-xtal/31245/8 "2019-10-30T12:27:35Z")

</div>

You should stop repeating that there are no practical issues with 8-bit MCU @8MHz.  
Practical issues that exist are clearly described below.

> [@cslorabox](#):
>
> > Apparently there ARE practical issues with 8-bit 8MHz MCU’s
> 
> No, there really are not.

This is incorrect.

> [@cslorabox](#):
>
> In other cases, the mistakes are bugs in a particular version of LMiC

Be specific: Which particular versions of LMIC are you referring to and what are those bugs?

> [@cslorabox](#):
>
> In some ports, for example, to the ESP32, the mistakes are appear to be downright absurd design decisions by the authors of the Arduino port.

**‘appear to be’** I have seen more remarks about timing issues of ESP32 in combination with LMIC, but instead of _hearsay_ it would be useful to add references to where this is actually _confirmed_ and _explained_ in detail.

> [@cslorabox](#):
>
> LMiC doesn’t need an RTOS, it has its own task scheduler.

Really? If true that should be able to solve all timing related LMIC-based-application issues.  
But unfortunately, it appears that just like the LMIC onEvent() event handler code should not spend to much time to handle events, the same accounts for LMIC Jobs that are scheduled by the LMIC scheduler, they should not spend too much time running. _I do not have a reference for this information at hand._

### Facts

- What are popular well-known boards using 8-bit MCU’s running at 8MHz?:  
Arduino Pro Mini 8Mhz and Adafruit/BSFrance LoRa32u4 (II).

- How many well-known Arduino LMIC implementations exist for 8-bit AVR MCU’s: **exactly two**.  
See: [Overview of LoRaWAN Libraries [HowTo]](https://www.thethingsnetwork.org/forum/t/overview-of-lorawan-libraries-lmic-loramac-node-and-their-variations-howto/24692)

- What is the most basic OTAA example that is included with each (Arduino) LMIC library?:  
**ttn-oota.ino**.

### Verified Facts

Are there any issues with 8-bit MCU’s running at 8 MHz in combination with Arduino framework and the two well known Arduino LMIC implementations? **Yes there are!**

A very simple test proves the facts:

- Take a BSFrance LoRa32 II v1.2 board.  
_Any of the boards mentioned should do but Pro Mini will require a separate SPI LoRa board._

- Use one of the two well-known Arduino LMIC libraries,  
either [LMIC-Arduino](https://github.com/matthijskooijman/arduino-lmic) or the newer and improved [MCCI LoRaWAN LMIC library](https://github.com/mcci-catena/arduino-lmic).

- Take the `ttn-otaa.ino` example (use the one that is included with the LMIC library used)  
and configure the correct lmic pinmappings for the board (don’t forget that for this board DIO1 must be manually wired) and enter the proper LoRaWAN keys/id’s.

- Upload the sketch to the board and let it run.

Will the sketch succeed to immediately join on SF7BW125 as it should?: NO  
Instead it will fail to join on SF7 and SF8 and only joins on SF9 instead.  
_As can be found in earlier posts on the forum._  
In practice this means that it will take 6+ to 8+ minutes before a join request succeeds.  
_And this does not even take into account the testing of proper handling of downlinks._

To solve the issue MAX\_CLOCK\_ERROR has to be set to a value higher than 0  
_(actual required value depends on hardware and LMIC library used)_.

The issues occur independent of which of the two LMIC libraries is used.

So are there any practical issues with 8-bit MCU’s @8MHz with Arduino + LMIC?: Definitely yes.  
_But they can be worked around by setting MAX\_CLOCK\_ERROR._

---

_[View the full topic](https://www.thethingsnetwork.org/forum/t/max-clock-error-vs-better-xtal/31245)._
