tftelkamp / arduino-lmic-v1.5

IBM LMIC v1.5 (LoRaWAN in C) adapted to run under the Arduino environment
43 stars 18 forks source link

Currently Teensy 3.0,3.1,3.2 get stuck #5

Closed sumotoy closed 8 years ago

sumotoy commented 8 years ago

I've connected as described, powering up the LoRa module NFR95W externally but the sample code provided stuck any Teensy 3 (even serial disappear). Same happen without module connected, Teensy get stuck and Teensy Loader ask to press the Reset Button. Teensy seems 'crashed', nothing work, Serial vanished, I have tried connect a mini TFT module (that uses SPI Transactions so it should be compatible with hal) but it doesn't initialize. Never happen before, very curious. I will investigate in these days. Using IDE 1.65 and Teensyduino 1.26b3

tftelkamp commented 8 years ago

Did you change the radio to sx1276 from sx1272 in config.h?

That might solve your problem.

Thomas

On 19 Dec 2015, at 19:29, max mc costa notifications@github.com wrote:

I've connected as described, powering up the LoRa module NFR95W externally but the sample code provided stuck any Teensy 3 (even serial disappear) Same happen without module connected, Teensy get stuck and Teensy Loader ask to press the Reset Button Teensy seems 'crashed', nothing work, Serial vanished, I have tried connect a mini TFT module (that uses SPI Transactions so it should be compatible with hal) but it doesn't initialize Never happen before, very curious I will investigate in these days Using IDE 165 and Teensyduino 126b3

— Reply to this email directly or view it on GitHub https://github.com/tftelkamp/arduino-lmic-v1.5/issues/5.

sumotoy commented 8 years ago

Thanks for fast response. Yes, I' have changed, but this not explain how the example cause the total crash of Teensy.

sumotoy commented 8 years ago

Looks like that os_init(); cause the complete crash of my Teensy 3.0, Teensy 3.1 and 3.2. I've just compiled this sketch for test:

#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>

lmic_pinmap pins = {
  .nss = 20,
  .rxtx = 7, // Not connected on RFM92/RFM95
  .rst = 15,  // Needed on RFM92/RFM95
  .dio = {2, 5, 6},
};

void setup() {
  Serial.begin(38400);
  long unsigned debug_start = millis ();
  while (!Serial && ((millis () - debug_start) <= 5000));
  Serial.println("started");
  os_init();// LMIC init
  Serial.println("inited");
}

void loop() {

}

It never reply 'inited' and serial disappear completely (aka..crash), Teensy loader ask for push reset button but serial appear for just some ms and disappear again, looks in total crash. This for every teensy 3, just tested even an Teensy LC, same. The os_init() cause the teensy crash

sumotoy commented 8 years ago

Ok, I find where the things goes wrong.

First, I have commented out this:

void os_init () {
    memset(&OS, 0x00, sizeof(OS));
    hal_init();
    radio_init();
    //LMIC_init();
}

This cause always a crash but I can get an error out of my terminal before everithing get stuck:

FAILURE
C:\Users\me\Documents\Arduino\libraries\arduino-lmic-v1.5-master\src\lmic\radio.cpp:657

this brings me to this line of code:

 ASSERT(v == 0x12 ); 

From this point Teensy goes in crash, serial disappear and I have to push reset and load any other schetch to revive it (included serial). hal inited succesfully btw so it doesn't seems an SPI low level routine issue.

tftelkamp commented 8 years ago

This means it does’t detect the LoRa chip (over the SPI bus).

Most likely a wiring problem?

Thomas

On 19 Dec 2015, at 22:13, max mc costa notifications@github.com wrote:

Ok, I find where the things goes wrong.

First, I have commented out this:

void os_init () { memset(&OS, 0x00, sizeof(OS)); hal_init(); radio_init(); //LMIC_init(); }

This cause always a crash but I can get an error out of my terminal before everithing get stuck:

FAILURE C:\Users\me\Documents\Arduino\libraries\arduino-lmic-v1.5-master\src\lmic\radio.cpp:657 this brings me to this line of code:

ASSERT(v == 0x12 ); From this point Teensy goes in crash, serial disappear and I have to push reset and load any other schetch to revive it (included serial). hal inited succesfully btw so it doesn't seems an SPI low level routine issue.

— Reply to this email directly or view it on GitHub https://github.com/tftelkamp/arduino-lmic-v1.5/issues/5#issuecomment-166024502.

sumotoy commented 8 years ago

Hi Thomas, find a problem with one of te 2 modules I have. Second one inited correctly. Thanks for advice! Just a suggestion, maybe modify the radio_init function to give back 0 if chip it's not recognized like if (!radio_init()){ print error and do not continue }. Great work! Really appreciate you used SPI transaction as well!