Closed ios198 closed 6 years ago
1 ticks of Timer0 ~ 4(us) => is that reason US_PER_OSTICK_EXPONENT = 4?
Nope, an "ostick" is the time unit internally used within LMIC and must be (according to original docs) 15.5μs - 100 μs. Arduino-LMIC chooses to make it 16us, which is 2^4, hence US_PER_OSTICK_EXPONENT=4
.
The complexity of this function is to deal with overflow: micros()
runs up to 2^32us, which corresponds to 2^28 osticks. To prevent the return value of hal_ticks()
from overflowing back to 0 when it reaches 2^28, a couple of extra bits are stored and incremented on such an overflow, so the hal_ticks()
return value only correctly runs up to 2^32 before overflowing.
#ifndef OSTICKS_PER_SEC
#define OSTICKS_PER_SEC 32768
This is just the LMIC default setting (used for the original ARM port, which uses ~30us per ostick), but on Arduino-LMIC this setting is overridden here:
Thank you for your explanation. Before closing this issue , I just want to ask that is this library still in development? I cannot find other LoraMac library for Arduino. And do you any plan porting Semtech LoraMac-node for Arduino? I found a library form here: https://github.com/arduino-org/arduino-library-lora-node-shield?utm_source=platformio&utm_medium=piohome But it not compatible with Arduino Avr boards.
I'm still planning to work on this library, but it's not a real priority right now. I looked at LoraMac-node, but I suspect it is too bulky for a small AVR devices (I haven't tried it, though). There is also a new stack recently developed which should be lightweight, but I'm not sure if there is an AVR/Arduino port yet: https://github.com/LoRaWanMiniMouse/Mini-Mouse
Both Semtech and TTN announced at the thing conference they will open source a lorawan stack for embedded devices Hope release will come soon
I think that the stack they announced is the mini-mouse one I linked in my previous comment. The dev branch seems to contain some code, the wiki some (badly converted) documentation, but I haven't had a proper look yet.
I am new to LMic library. I successfully port Lmic library to Arduino Uno and tested raw.ino example. I dont really completely understand this hal_ticks() function.
*For example with the typical Arduino has a 16MHz oscillator: 1 ticks of Timer0 ~ 4(us) => is that reason US_PER_OSTICK_EXPONENT = 4? scaled= number of ticks = (micors() >> US_PER_OSTICK_EXPONENT ) = ((timer0_overflow_count << 8) + TCNT0)/4 and I dont know how to explain next parts to really get the meaning of this function.