Big STM32 boards topic

i’ve somehow managed to send data to TTN. it is shown in ttn applications>data section with proper variables with ABP. OTAA still doesn’t work…callback works properly now in ABP i can see TX_COMPLETE event. this is with the “official” stm32core which supports stm32 hal…https://github.com/stm32duino/Arduino_Core_STM32

In the current form the sketch looks like this: https://github.com/iotlearner0level/TTN-OLED-SENSORNODE-STM32/blob/master/v3oled.ino
lora modem (sx1278 based aithinker ra02) is connected to SPI1 an OLED ssd1306 is connected to i2c1 (pa6/7) bmp180 is connected to pa10/11 it takes power from gpio pins (low power device, so it should be ok) i’ve redefined bmp180.h and bmp180.c to used twowire on those two pins for the bmp. rest of the sketch is based on tomtor’s solar example but i’ve removed all the sleep statements. apparently, sleep in the official core works a bit different.

The keypoint was that we have to disable in the libraries nointerrupts and disablehal and it seems to work ok.

now i want two additional features:

  • I am testing various batteries (nimhx4, nicdx4, 1-18650 connected to Vin pin, 2x18650 lipo connected to Vin) so i also need to send Vcc voltage. How to get Vcc in stm32. method prescribed in original sketch doesn’t seem to work…
  • SLEEP Mode, which seem to work differently in the official core

thanks

I am using this code to read the voltage without an external voltage divider:

int readVInt()
{
  adc_enable(ADC1);

  adc_reg_map *regs = ADC1->regs;
  regs->CR2 |= ADC_CR2_TSVREFE; // enable VREFINT and temp sensor
  regs->SMPR1 = (ADC_SMPR1_SMP17); // sample rate for VREFINT ADC channel

  int vref = 1210 * 4096 / adc_read(ADC1, 17); // ADC sample to millivolts
  regs->CR2 &= ~ADC_CR2_TSVREFE; // disable VREFINT and temp sensor
  return vref;
}

This gives compiler error for the hal enabled core at GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino :
C:\Users\XYZ\Documents\Arduino\stm32\sketch_apr23a\sketch_apr23a.ino: In function ‘int readVInt()’:

sketch_apr23a:12: error: 'adc_enable' was not declared in this scope

   adc_enable(ADC1);

                  ^

sketch_apr23a:14: error: 'adc_reg_map' was not declared in this scope

   adc_reg_map *regs = ADC1->regs;

   ^~~~~~~~~~~

sketch_apr23a:14: error: 'regs' was not declared in this scope

   adc_reg_map *regs = ADC1->regs;

                ^~~~

sketch_apr23a:14: error: 'struct ADC_TypeDef' has no member named 'regs'

   adc_reg_map *regs = ADC1->regs;

                             ^~~~

sketch_apr23a:18: error: 'adc_read' was not declared in this scope

   int vref = 1210 * 4096 / adc_read(ADC1, 17); // ADC sample to millivolts

                                             ^

exit status 1
'adc_enable' was not declared in this scope

after some google search, hal adc for bluepill stm32f103 boards are defined here:

I can’t make much ot of it right now. maybe i’ve to spend lots of time to figure out how that works.

Just in case anyone is interested in the “official” stm32 core GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino

Based on fpiSTM’s suggestion from the stm32duino forums, we can read chip voltage & temperature using the following:

uint16_t adc_read(uint32_t channel)
{
  ADC_HandleTypeDef AdcHandle = {};
  ADC_ChannelConfTypeDef  AdcChannelConf = {};
  __IO uint16_t uhADCxConvertedValue = 0;

  AdcHandle.Instance = ADC1;
  AdcHandle.State = HAL_ADC_STATE_RESET;
  AdcHandle.Init.DataAlign             = ADC_DATAALIGN_RIGHT;           /* Right-alignment for converted data */
  AdcHandle.Init.ScanConvMode          = DISABLE;                       /* Sequencer disabled (ADC conversion on only 1 channel: channel set on rank 1) */
  AdcHandle.Init.ContinuousConvMode    = DISABLE;                       /* Continuous mode disabled to have only 1 conversion at each conversion trig */
  AdcHandle.Init.DiscontinuousConvMode = DISABLE;                       /* Parameter discarded because sequencer is disabled */
  AdcHandle.Init.ExternalTrigConv      = ADC_SOFTWARE_START;            /* Software start to trig the 1st conversion manually, without external event */
  AdcHandle.Init.NbrOfConversion       = 1;                             /* Specifies the number of ranks that will be converted within the regular group sequencer. */
  AdcHandle.Init.NbrOfDiscConversion   = 0;                             /* Parameter discarded because sequencer is disabled */

  if (HAL_ADC_Init(&AdcHandle) != HAL_OK) {
    return 0;
  }

  AdcChannelConf.Channel      = channel;             /* Specifies the channel to configure into ADC */
  AdcChannelConf.Rank         = ADC_REGULAR_RANK_1;               /* Specifies the rank in the regular group sequencer */
  AdcChannelConf.SamplingTime = ADC_SAMPLETIME_13CYCLES_5;                     /* Sampling time value to be set for the selected channel */

  /*##-2- Configure ADC regular channel ######################################*/
  if (HAL_ADC_ConfigChannel(&AdcHandle, &AdcChannelConf) != HAL_OK)
  {
    /* Channel Configuration Error */
    return 0;
  }
  /*##-2.1- Calibrate ADC then Start the conversion process ####################*/
  if (HAL_ADCEx_Calibration_Start(&AdcHandle) !=  HAL_OK) {
    /* ADC Calibration Error */
    return 0;
  }
  /*##-3- Start the conversion process ####################*/
  if (HAL_ADC_Start(&AdcHandle) != HAL_OK) {
    /* Start Conversation Error */
    return 0;
  }
  /*##-4- Wait for the end of conversion #####################################*/
  /*  For simplicity reasons, this example is just waiting till the end of the
      conversion, but application may perform other tasks while conversion
      operation is ongoing. */
  if (HAL_ADC_PollForConversion(&AdcHandle, 10) != HAL_OK) {
    /* End Of Conversion flag not set on time */
    return 0;
  }
  /* Check if the continous conversion of regular channel is finished */
  if ((HAL_ADC_GetState(&AdcHandle) & HAL_ADC_STATE_REG_EOC) == HAL_ADC_STATE_REG_EOC) {
    /*##-5- Get the converted value of regular channel  ########################*/
    uhADCxConvertedValue = HAL_ADC_GetValue(&AdcHandle);
  }

  if (HAL_ADC_Stop(&AdcHandle) != HAL_OK) {
    /* Stop Conversation Error */
    return 0;
  }
  if(HAL_ADC_DeInit(&AdcHandle) != HAL_OK) {
    return 0;
  }
  return uhADCxConvertedValue;
}

void setup() {
  Serial.begin(115000);
  analogRead(A0); // Workaround to init g_current_pin used in HAL_ADC_MspInit
}

void loop() {
  float Vdd = readVdd();
  Serial.print("Vdd=  ");
  Serial.print(Vdd);
  Serial.print(" V Temp= ");
  Serial.print(readTempSensor(Vdd));
  Serial.println(" °C");
  delay(500);
}

static float readVdd()
{
  return (1.20 * 4096.0 / adc_read(ADC_CHANNEL_VREFINT)); // ADC sample to V
  //return (1200 * 4096 / adc_read(ADC_CHANNEL_VREFINT)); // ADC sample to mV
}

static float readTempSensor(float Vdd)
{
  return ((1.43 - (Vdd / 4096.0 * adc_read(ADC_CHANNEL_TEMPSENSOR))) / 0.0043 + 25.0);
}

I’ve also updated my sketch which now sends bmp180 Pressure,temperature, altitude, chip temperature and Vdd. Vdd is especially helpful in battery operated scenarios.

sketch is here:

TTN-OLED-SENSORNODE-STM32/v4oled.ino at master ¡ iotlearner0level/TTN-OLED-SENSORNODE-STM32 ¡ GitHub

In addition, fpiSTM has indicated that sleep/low power API will be available soon, so it may be a matter of a few weeks or a month and we can use arduino library calls for low power without even using register stuff.

Just of reference, i’ve created a link to reading Vdd/chip temperature in official core just in case it is useful:

1 Like

Just in case anyone interested, bluepill boards seem to work upto 2.0V@72Mhz. I’ve connected 4xNiMh to Vin (5V input) Fully charged it starts from 5.4V then keeps on dropping…I get around 10hours with everything running (around 80mA, approx 50mA for the bluepill+lora and another 30mA for an electrical parameter tester)

From the voltage levels reported by chip, it seems it works ok upto 2.0V along with the lora radio (aithinker ra02/sx1278) without any special low frequency mode. bmp180 (connected to GPIO pins for Vcc/GND) also seem to work. last correct reading shows voltage of 2.67V (for the stm32). but the oled did not work that low…

here is o/p from the TTN storage integration console:

  {
    "altitude": 173,
    "chipTemp": 45.51,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACtCPcRxw==",
    "temperature": 32.7,
    "time": "2018-04-26T15:08:31.886672246Z",
    "voltage": 2.295
  },
  {
    "altitude": 173,
    "chipTemp": 49.07,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACtCJwTKw==",
    "temperature": 32.7,
    "time": "2018-04-26T15:09:43.815344082Z",
    "voltage": 2.204
  },
  {
    "altitude": 173,
    "chipTemp": 48.57,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACtCK8S+Q==",
    "temperature": 32.7,
    "time": "2018-04-26T15:09:48.870310385Z",
    "voltage": 2.223
  },
  {
    "altitude": 173,
    "chipTemp": 47.48,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACtCKwSjA==",
    "temperature": 32.7,
    "time": "2018-04-26T15:09:59.018495216Z",
    "voltage": 2.22
  },
  {
    "altitude": 173,
    "chipTemp": 48.14,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACtCKASzg==",
    "temperature": 32.7,
    "time": "2018-04-26T15:10:09.111891725Z",
    "voltage": 2.208
  },
  {
    "altitude": 172,
    "chipTemp": 47.36,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsCL0SgA==",
    "temperature": 32.7,
    "time": "2018-04-26T15:10:14.443139847Z",
    "voltage": 2.237
  },
  {
    "altitude": 172,
    "chipTemp": 48.53,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsCJYS9Q==",
    "temperature": 32.7,
    "time": "2018-04-26T15:10:21.023027081Z",
    "voltage": 2.198
  },
  {
    "altitude": 173,
    "chipTemp": 48.65,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACtCI0TAQ==",
    "temperature": 32.7,
    "time": "2018-04-26T15:10:27.35627427Z",
    "voltage": 2.189
  },
  {
    "altitude": 172,
    "chipTemp": 49.24,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsCIYTPA==",
    "temperature": 32.7,
    "time": "2018-04-26T15:10:33.76306509Z",
    "voltage": 2.182
  },
  {
    "altitude": 173,
    "chipTemp": 48.93,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACtCIETHQ==",
    "temperature": 32.7,
    "time": "2018-04-26T15:10:39.810258704Z",
    "voltage": 2.177
  },
  {
    "altitude": 173,
    "chipTemp": 49.44,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACtCHcTUA==",
    "temperature": 32.7,
    "time": "2018-04-26T15:10:45.594316777Z",
    "voltage": 2.167
  },
  {
    "altitude": 112,
    "chipTemp": 50.59,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 999,
    "raw": "BQAD5wBwCGoTww==",
    "temperature": 12.8,
    "time": "2018-04-26T15:10:54.261388134Z",
    "voltage": 2.154
  },
  {
    "altitude": 112,
    "chipTemp": 50.82,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 999,
    "raw": "BQAD5wBwCFkT2g==",
    "temperature": 12.8,
    "time": "2018-04-26T15:11:02.42113182Z",
    "voltage": 2.137
  },
  {
    "altitude": 112,
    "chipTemp": 50.96,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 999,
    "raw": "BQAD5wBwCE0T6A==",
    "temperature": 12.8,
    "time": "2018-04-26T15:11:10.264988356Z",
    "voltage": 2.125
  },
  {
    "altitude": 112,
    "chipTemp": 51.08,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 999,
    "raw": "BQAD5wBwCEQT9A==",
    "temperature": 12.8,
    "time": "2018-04-26T15:11:17.896079546Z",
    "voltage": 2.116
  },
  {
    "altitude": 112,
    "chipTemp": 51.41,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 999,
    "raw": "BQAD5wBwCD0UFQ==",
    "temperature": 12.8,
    "time": "2018-04-26T15:11:25.272545344Z",
    "voltage": 2.109
  },
  {
    "altitude": 112,
    "chipTemp": 50.77,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 999,
    "raw": "BQAD5wBwCDgT1Q==",
    "temperature": 12.8,
    "time": "2018-04-26T15:11:32.674394192Z",
    "voltage": 2.104
  },
  {
    "altitude": 112,
    "chipTemp": 52,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 999,
    "raw": "BQAD5wBwCCIUUA==",
    "temperature": 12.8,
    "time": "2018-04-26T15:11:41.797026116Z",
    "voltage": 2.082
  },
  {
    "altitude": 172,
    "chipTemp": 52.94,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsCA8Urg==",
    "temperature": 32.7,
    "time": "2018-04-26T15:11:47.370536356Z",
    "voltage": 2.063
  },
  {
    "altitude": 172,
    "chipTemp": 52.39,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsCAwUdw==",
    "temperature": 32.7,
    "time": "2018-04-26T15:11:52.945451005Z",
    "voltage": 2.06
  },
  {
    "altitude": 172,
    "chipTemp": 52.48,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsCAUUgA==",
    "temperature": 32.7,
    "time": "2018-04-26T15:11:58.259530726Z",
    "voltage": 2.053
  },
  {
    "altitude": 173,
    "chipTemp": 52.8,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACtB/8UoA==",
    "temperature": 32.7,
    "time": "2018-04-26T15:12:03.329723118Z",
    "voltage": 2.047
  },
  {
    "altitude": 172,
    "chipTemp": 52.65,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsB/gUkQ==",
    "temperature": 32.7,
    "time": "2018-04-26T15:12:08.406844851Z",
    "voltage": 2.04
  },
  {
    "altitude": 172,
    "chipTemp": 53.55,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsB/AU6w==",
    "temperature": 32.7,
    "time": "2018-04-26T15:12:13.211109286Z",
    "voltage": 2.032
  },
  {
    "altitude": 172,
    "chipTemp": 53.27,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsB+sUzw==",
    "temperature": 32.7,
    "time": "2018-04-26T15:12:17.761658036Z",
    "voltage": 2.027
  },
  {
    "altitude": 172,
    "chipTemp": 54.03,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsB+UVGw==",
    "temperature": 32.7,
    "time": "2018-04-26T15:12:22.332773405Z",
    "voltage": 2.021
  },
  {
    "altitude": 172,
    "chipTemp": 54.47,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsB94VRw==",
    "temperature": 32.7,
    "time": "2018-04-26T15:12:26.623906536Z",
    "voltage": 2.014
  },
  {
    "altitude": 172,
    "chipTemp": 53.86,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsB9cVCg==",
    "temperature": 32.7,
    "time": "2018-04-26T15:12:30.66988373Z",
    "voltage": 2.007
  },
  {
    "altitude": 172,
    "chipTemp": 54.36,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DMYD4ACsB9QVPA==",
    "temperature": 32.7,
    "time": "2018-04-26T15:12:34.728438098Z",
    "voltage": 2.004
  },
  {
    "altitude": 172,
    "chipTemp": 55.15,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DLsD4ACsB8oViw==",
    "temperature": 32.59,
    "time": "2018-04-26T15:12:43.351249396Z",
    "voltage": 1.994
  },
  {
    "altitude": 169,
    "chipTemp": 42.37,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 993,
    "raw": "DIkD4QCpDM4QjQ==",
    "temperature": 32.09,
    "time": "2018-04-26T15:48:49.328256588Z",
    "voltage": 3.278
  },
  {
    "altitude": 170,
    "chipTemp": 46.4,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 993,
    "raw": "DIkD4QCqDMESIA==",
    "temperature": 32.09,
    "time": "2018-04-26T15:50:02.785980618Z",
    "voltage": 3.265
  },
  {
    "altitude": 169,
    "chipTemp": 45.49,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 993,
    "raw": "DIkD4QCpDNMRxQ==",
    "temperature": 32.09,
    "time": "2018-04-26T15:51:17.9793614Z",
    "voltage": 3.283
  },
  {
    "altitude": 169,
    "chipTemp": 44.37,
    "device_id": "lora-gateway-node-ra01",
    "pressure": 992,
    "raw": "DJQD4ACpDNMRVQ==",
    "temperature": 32.2,
    "time": "2018-04-26T15:52:33.173748387Z",
    "voltage": 3.283
  },

Better leave some of it. :grin:

Problems with Arduino-LMIC and the offficial STM32 Arduino Core

I have seen this mentioned in several places but I cannot recall having seen it explained with a single good solution to fix it. I hope I just overlooked. :slightly_smiling_face:

I have some sketches that worked with the STM32F103C8T6 (128kb) ‘bluepill’ board + RFM95W when using Roger Clarks ‘stmduino core’.
But when I try the same sketches with the official STM32 Arduino Core then the code somewhere fails (LMIC-Arduino related).

Can anyone explain why this happens and what is the best way to fix it.

With ‘best way’ I mean, the most proper / most correct / most future proof / best maintainable / lowest impact / best craftsmanship way (if you get my point).

1 Like

to quote fpiSTM (official maintainer of the project)

STM core uses CMSIS so the way accessing registers is different.

Roger clark core is based on libmaple (GitHub - leaflabs/libmaple: [INACTIVE] C and C++ library for STM32 ARM Cortex-M3 development boards. and documentation: http://docs.leaflabs.com/docs.leaflabs.com/index.html )

I do not understand the internal details, so can’t go deeper. There is nothing futureproof, anything new breaks old :slight_smile: Hoever, any specific queries can be resolved by raising issues in the github for the official core or in stm32duino forum.

Yes, I was aware of that already, thanks.
But now I’m looking for a good solution and try to avoid poorly maintainable custom hacks where possible.
I would prefer a wrapper / compatibility layer / abstraction-layer-like solution that hides away implementation differences from application code (and libraries). Which is why you would normally use a (Hardware) Abstraction Layer. And a HAL is exactly what the official STM32 Arduino Core is based on (a HAL that hides away implementation differences of different STM32 MCU’s).
In this case the STM32 Arduino Core introduces an incompatibility for LMIC-Arduino that Roger’s stmduino core does not appear to suffer from. This is an incompatibility with Arduino (not an incompatibility with stm32duino core).

Having some STM supported automated conversion tool that can translate differences (where possible) would be great. Or at least have a compatibility scanner that can check existing Arduino code for possible conflict areas that need attention / require changes. That would be more preferable and much more productive than having to follow the ‘oops this doesn’t work, appears to be incompatible, now start looking where to fix this’ manual approach for existing sketches and libraries.

My opinion is that it is better to use the official STM32 Arduino Core instead of the Maple based stm32duino core and try to get ironed out any issues and incompatibilities where possible.
Roger’s older Maple based stm32duino is based on a fixed architecture from specific STM32 MCU model(s) and does not allow to be (easily) adapted for and provide support for newer STM32 MCU’s and is not supported by STM (STM32 Arduino Core is). So it is much less future proof. But I am unaware of what STM’s support for STM32 Arduino Core actually includes.

I think with ‘upto’ you meant ‘down to’. :slightly_smiling_face:

Of course I got the message what you meant with upto. That’s why I put a smile next to it.
But it was funny, because the statement was ‘look how low it can go’. (Non-native English speaker here too.)
No pun intended. :slightly_smiling_face:

I have used the bluepill with RFM95W without any problems (yet), using the default SPI pins as defined in the Arduino’s board/variants definition. Just some basic test sketches using LMIC Arduino (nothing advanced yet).

2 Likes

Sorry wasn’t clear enough. i meant to get both the spi1 and spi2 working also both the i2c1 and i2c2 working as there are two of these. so if i want to connect a max7219 on spi2, i think it is somewhat difficult for a new person. for i2c i wanted save hassle of wiring everything together and i connected oled and bmp180 to different i2c1 and i2c2. somehow from the schematic, http://wiki.stm32duino.com/index.php?title=File:Bluepillpinout.gif i was confused whether pb8/9 were scl/sda or pb6/7. it is all defined in pinvariants but somewhat difficult to follow for a hobbyist. i used i2c 2 because somehow i thought i will switch of i2c1 (oled) altogether if not required. but i had to modify bmp180 library. so it reads something like TwoWire tire(pb11,pb10) rather than Wire() and i replaced all Wire with tire to use the second i2c.

And no offence for that remark, fighting over wordplay was our favourite national passtime before facebook/instagram was inveted. i can go on for years :smiley:

I did exactly the same for both SPI and I2C: use the default pins as defined in the Arduino’s board/variant definitions (both working fine). :grin:

Sorry wasn’t clear enough (v2). i meant to get both the spi1 and spi2 working also both the i2c1 and i2c2 working as there are two of these.

Ah ok.

You normally would need only need a single I2C interface for multiple devices because they can share the same bus. The same holds for SPI (but would require a separate SS pin per device on the bus). But in very time critical situations using separate interfaces of the same type may prove useful or even be required but I have little experience with that (in case of the non-interrupt driven time-critical LMIC-Arduino library using a separate SPI bus might be useful).

@bluejedi @lorawanhere Ok Guys supposedly native English ‘grunter’ here…now you have me real confused… there was I thinking this (2.0V @ 72Mhz) was a ref to holding voltage steady @ 2V then steadily increasing op freq (say 16Mhz to 32Mhz to 48Mhz…) …up to 72Mhz! :wink: Tee Hee <VBCG> :smile: (okay fact the upto is before the voltage vs @ ‘upto’ the freq tells real story but truth is English can sometimes be a bit of a pig I guess :wink: )

@Jeff-UK

There was no mentioning of frequencies.

Oh my, there was…

upto 2.0V@72Mhz

I just missed it (my own quote). :blush: :wink:

<VBCG> = very big cheezy grin…more a comment on the peculiarities of language & how things can be open to interpretation than the actual statement…smoking? - maybe I should start…:wink:

2 Likes
LoRaM3-D boards

Did anyone succeed in getting these boards to work with the LMIC-Arduino library yet?

I have been experimenting with some LoRaM3-D boards but dit not get them to work with LMIC-Arduino yet.
Hangs during call to os_init().

For developing with the Arduino Framework, the boards require the following Arduino core: https://github.com/BSFrance/BSFrance-stm32 (The repo currently lacks some tools, they have to be installed manually. I’m working on things, will post more info later.)

I saw a tip on github to work around some path too long issues: Set temp and tmp environment variables to C:\Temp (not sure if it will help much).

1 Like

LoRaM3-D V1.1 Arduino IDE

With my installation, I found several things missing to compile in Arduino:
In BSFrance-stm32-master/stm32/tools/win/gcc/bin/arm-none-eabi-g++ stuff is missing.
I copied the contents of gcc-arm-none-eabi-7-2017-q4-major-win32.zip from https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads to here: \hardware\BSFrance-stm32-master\stm32\tools\win\gcc

Next was about the dfu-util-static which was missing:
Downloaded it: http://dfu-util.sourceforge.net/ and put the dfu-util-static.exe here: \hardware\BSFrance-stm32-master\stm32\tools\win

Finally I was able to compile and upload blink.

The LMIC I have the same problems as were mentioned before by others. The processor freezes when os_init() is called. From the posts above, I cannot understand if there is a solution and which.
Anyone got this resolved and the OTAA-example working?

Issue SOLVED :slightly_smiling_face:

(Solution based on @tomtor’s LMIC-Arduino fork.)

The LMIC-Arduino OTAA and ABP examples (ttn-otaa.ino and ttn-abp.ino) are now working with BSFrance-stm32 core with all three BSFrance LoRaM3-D boards:

  • LoRaM3-D L151
  • LoRaM3-D F103
  • LoRaM3-D F303

How to apply the fix:

In LMIC-Arduino src\hal\hal.cpp

Replace:

static uint8_t irqlevel = 0;

void hal_disableIRQs () {
    noInterrupts();
    irqlevel++;
}

void hal_enableIRQs () {
    if(--irqlevel == 0) {
        interrupts();

        // Instead of using proper interrupts (which are a bit tricky
        // and/or not available on all pins on AVR), just poll the pin
        // values. Since os_runloop disables and re-enables interrupts,
        // putting this here makes sure we check at least once every
        // loop.
        //
        // As an additional bonus, this prevents the can of worms that
        // we would otherwise get for running SPI transfers inside ISRs
        hal_io_check();
    }
}

With:

#ifdef ARDUINO_ARCH_STM32

    // Fix for STM32 HAL based cores.

    // ARDUINO_ARCH_STM32 appears to be defined for these Arduino cores:
    // - Arduino_Core_STM32 (aka stm32duino)
    // - STM32GENERIC
    // - BSFrance-stm32

    // This fix solves an issue with STM32 HAL based Arduino cores where 
    // a call to os_init() hangs the MCU. The fix prevents LMIC-Arduino from 
    // disabling and re-enabling interrupts.
    // While the exact cause is not known, it is assumed that disabling interrupts 
    // may conflict with interrupts required for the STM32 HAL core.
    // (Possible side-effects on LMIC timing have not been checked.)

    void hal_disableIRQs () {
    }

    void hal_enableIRQs () {
        hal_io_check();
    }
    
#else

    static uint8_t irqlevel = 0;

    void hal_disableIRQs () {
        noInterrupts();
        irqlevel++;
   }

   void hal_enableIRQs () {
       if(--irqlevel == 0) {
           interrupts();

           // Instead of using proper interrupts (which are a bit tricky
           // and/or not available on all pins on AVR), just poll the pin
           // values. Since os_runloop disables and re-enables interrupts,
           // putting this here makes sure we check at least once every
           // loop.
           //
           // As an additional bonus, this prevents the can of worms that
           // we would otherwise get for running SPI transfers inside ISRs
           hal_io_check();
       }
   }
    
#endif
4 Likes