EnviroDIY / Arduino-SDI-12

An Arduino library for SDI-12 communication with a wide variety of environmental sensors. This library provides a general software solution, without requiring any additional hardware.
https://github.com/EnviroDIY/Arduino-SDI-12/wiki
BSD 3-Clause "New" or "Revised" License
164 stars 100 forks source link

Lockup on SAMD Based Arduino MKR 1500 #53

Closed bleckers closed 5 years ago

bleckers commented 5 years ago

I am experiencing a lockup issue with the operation of this library on the newer MKR 1500 (ATSAMD21G18 based). This happens with the verbatim check_all_addresses example and current version of the library when you try to do any SDI-12 operations.

At first I thought it might be clock gen/TC conflicts, but running the configSDI12TimerPrescale on it's own works just fine. Then I thought it might be the USB CDC interface being problematic with the way the global interrupts are being disabled, but disabling all Serial operations (just had an LED set up to blink after each operation) doesn't stop the lockups.

These lockups happen just the standalone board (nothing is connected to any pins and just being powered from 5V) or with USB connected.

The differences between the Zero and MKR 1500 are here in the variants files (left is Zero, right is MKR1500) - variant.h - https://www.diffchecker.com/3s0SIx1t , variant.cpp - https://www.diffchecker.com/iWa7l4fq

These are the same files as the ones in here - https://github.com/arduino/ArduinoCore-samd/tree/master/variants

This is being compiled with Arduino 1.8.6 and v1.8.3 of the SAMD boards libraries.

Is there anything that I am missing?

bleckers commented 5 years ago

Turns out it's something up with passing the object in that example.

If you change the example to pass the object as a pointer (and use the different begin function):

 SDI12 mySDI12;

  pinMode(sensorPins[pin], INPUT);
  mySDI12.begin(sensorPins[pin]);
  Serial.print("Checking pin ");
  Serial.print(sensorPins[pin]);
  Serial.println("...");
  scanAddressSpace(&mySDI12);
  mySDI12.end();

And also change the supporting functions to pass in as pointer (e.g. void printInfo(SDI12 * sdi, char i){) as well as how you reference the sdi object (from . to ->) it works just fine and dandy.

There must be something up possibly with the newer versions of the compiler.

SRGDamia1 commented 5 years ago

So, is this something to fix or not?

bleckers commented 5 years ago

I reopened this issue with something that was slightly related. But it turned out after getting the original issue with the pointers sorted, plugging the Arduino into a daughterboard with level converters caused this related issue. It was outputting a 48MHz signal which I thought might have been related to the clock gen/TC, but it turns out it was the level converter (TXB0108) causing problems.

As for what caused this original issue. Is it reproducible on other SAMD boards with the examples and the latest SAMD libraries/compilers?

SRGDamia1 commented 5 years ago

I haven't had any problems recently with my Feather M0.

Level converters are often a hassle.