# Can LMIC 1.6 be set up to use a single channel and SF?

**URL:** <https://www.thethingsnetwork.org/forum/t/can-lmic-1-6-be-set-up-to-use-a-single-channel-and-sf/5207>\
**Category:** End Devices (Nodes)\
**Created:** [February 4, 2017, 10:43am UTC](https://www.thethingsnetwork.org/forum/t/can-lmic-1-6-be-set-up-to-use-a-single-channel-and-sf/5207 "2017-02-04T10:43:39Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [March 1, 2018, 6:39am UTC](https://www.thethingsnetwork.org/forum/t/can-lmic-1-6-be-set-up-to-use-a-single-channel-and-sf/5207/12 "2018-03-01T06:39:26Z")

</div>

For the US, which uses 64 channels while gateways might only use 8 (or one, for a single-channel gateway), the following **from April 2016** might be relevant:

> [@Node with ESP8266 and RFM95W](https://www.thethingsnetwork.org/forum/t/node-with-esp8266-and-rfm95w/1002/53):
>
> Huh, turns out the lmic.cpp LMIC\_disableChannel(u1\_t channel) for CFG\_us915 I got from [LoRa-Thing/libraries/lmic-v1.5 at master · things4u/LoRa-Thing · GitHub](https://github.com/things4u/LoRa-Thing/tree/master/libraries/lmic-v1.5) is broken - for
> 
> ```cpp
> struct lmic_t {
> #elif defined(CFG_us915)
> u2_t channelMap[(72+MAX_XCHANNELS+15)/16]; // enabled bits
> 
> ```
> 
> that should be an array of 5 16 bit values (80 bits, to cover 74 total channels), which when initialized is:
> 
> ```cpp
> LMIC.channelMap[0] = 0xFFFF 16
> LMIC.channelMap[1] = 0xFFFF 32
> LMIC.channelMap[2] = 0xFFFF 48
> LMIC.channelMap[3] = 0xFFFF 64
> LMIC.channelMap[4] = 0x00FF 72 bits
> 
> ```
> 
> However, LMIC\_disableChannel() for CFG\_us915 is modulo 4???
> 
> ```cpp
> LMIC.channelMap[channel/4] &= ~(1<<(channel&0xF));
> 
> ```
> 
> should be 16. As it is, when you disable channel 4, you actually get 20!
> 
> ```plaintext
> 4: channelMap[0]: ffff  
> channelMap[1]: ffef 1110 1111 wtf??
> 
> ```
> 
> LMIC\_disableChannel(8) turns off the bit for 40, etc. Changed it to:
> 
> ```cpp
> LMIC.channelMap[channel/16] &= ~(1<<(channel&0xF));
> 
> ```

And:

> [@Node with ESP8266 and RFM95W](https://www.thethingsnetwork.org/forum/t/node-with-esp8266-and-rfm95w/1002/56):
>
> [https://github.com/matthijskooijman/arduino-lmic/blob/master/src/lmic/lmic.c](https://github.com/matthijskooijman/arduino-lmic/blob/master/src/lmic/lmic.c)
> 
> has the same bug:
> 
> ```cpp
> void LMIC_disableChannel (u1_t channel) {
> if( channel < 72+MAX_XCHANNELS )
> LMIC.channelMap[channel/4] &= ~(1<<(channel&0xF));      
> }
> 
> ```
> 
> That 4 should be a 16 to get the right byte of the array - only affects CFG\_us915

I’ve not validated, but someone might want to create a pull request if this bug is currently still in the code

---

_[View the full topic](https://www.thethingsnetwork.org/forum/t/can-lmic-1-6-be-set-up-to-use-a-single-channel-and-sf/5207)._
