mcci-catena / arduino-lmic

LoraWAN-MAC-in-C library, adapted to run under the Arduino environment
https://forum.mcci.io/c/device-software/arduino-lmic/
MIT License
641 stars 208 forks source link

hal_ticks() / os_getTime() don't work properly on Adafruit BSP #45

Closed terrillmoore closed 6 years ago

terrillmoore commented 6 years ago

I had a problem with a hang when waiting for a large number of osticks (100 ms worth) running on the Feather M0 LoRa with the MCCI 1.0.4 BSP.

Investigation with prints() revealed that os_getTime() was limited (over a very large number of calls) to a range of 62 values.

junk.txt

The following awk command was used to investigate:

$ awk 'BEGIN { Max = 0; Min = 2000000; } { if ($3 > Max) Max = $3 ; if ($3 < Min) Min = $3; } END { printf("min: %x max: %x diff: %d\n", Min, Max, Max-Min); }' /c/tmp/junk.txt
min: 1069a9 max: 1069e7 diff: 62

I have not yet investigated the source of this; looking at hal_ticks() it seems that the only way this can happen is due to a bug in micros() (for example, it is only a 16-bit value). But this needs to be fixed!

terrillmoore commented 6 years ago

Turns out this was a BSP problem; interrupts are left disabled except during a call to yield()...