Big STM32 boards topic

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

Did you ever manage to get lower current in sleep ( ~300uA during full sleep from BSFrance?)
Would really like to get a battery powered device out there; wondering if this is the right board to start with or if we basically must do our own circuits to get rid of the charging circuit/regulator to reduce power when not being used

I have not done any real power measurements yet, but I do know that unfortunately, the current versions of the boards were not designed with low power in mind.

There is a 10k BOOT0 pull-up resistor, normally connected to ground so during normal use it draws a constant current of around 330uA. (Not what is expected from a board that supports to be battery powered.)
There also is a dual 100k resistor divider connected to PA1 for battery monitoring. With a LiPo or Li-Ion battery connected this will constantly draw around 18uA of current (assuming a battery voltage of 3.7V).

Okay good to know. Still trying to decide whether to start with one of these boards or a TTGO V2 :thinking:

Lowest power seen in this thread for this board: @JTP “1.- Sleep mode: 0.13mA”
Any other lower bidders?

@bluejedi
:+1:
Pretty cool man, thank you so much! And of course special thanks to tomtor.
It works.

I already tested the [LMIC-arduino by @tomtor (https://github.com/tomtor/arduino-lmic) before but it did not work for me. So, it might be interesting for future users that in his code, he has the condition:
#ifdef ARDUINO_ARCH_STM32F1
which did not work.
I exchanged it for the suggested
#ifdef ARDUINO_ARCH_STM32
and now it does.

1 Like

This will depend on the Arduino core that you use.

Take care with Tom’s LMIC fork. He has disabled the receive Window which is not compliant with LoRaWAN.
And he uses it with Roger Clark’s Arduino_STM32 core, not a HAL based core like BSFrance-stm32, hence the check for ARDUINO_ARCH_STM32F1. Unfortunately different cores do not behave exactly identical.

I have the sample sketches running on a bluepill with Roger’s Arduino_STM32 core and for that I did not have to prevent LMIC disabling interrupts. So I just use LMIC-Arduino as is, without changes. Works with both the OTAA and ABP standard examples. (Possibly Tom has ran into issues that I have not ran into yet.)

@bluejedi
Ok, I will. Thanks for the warning.
I switched over to the LMIC from matthijskooijman and with your modifications, of course it runs.

However, nothing is ever free in the Arduino world: Now, as soon as I add the os_init(); into my code, the u8g2-library stops working. I need to investigate further if I messed something up or if there is a real problem … or use a different library for the OLED.

Tom added some other changes related to STM32 deep sleep. These may be useful also for a HAL based core (but I have not looked at that yet).

I have the normal LMIC-Arduino library (with my above fix) running with BSFrance-stm32 with normally working OLED display using U8g2 on the LoRaM3-D boards.

I plan to post some complete samples that will work out of the box for several boards / MCU’s, including the LoRaM3-D boards (only the TTN related parameters need to be configured).

1 Like

@bluejedi
Very strange. I must be doing something wrong.
What pinmapping do you use then? Did you connect Pin 101 which I interpret as being DIO1?

I connect DIO1 to PB0. Yes the “IO” actually means “DIO” (little space for the text labels).

I use U8x8. SSD1306 hardware I2C constructor.
I only specify the reset pin (check U8g2/U8x8 docs for proper constructor syntax).
SCL and SDA are already defined in the board definition.

Please note BSFrance-stm32 currently has a bug in the F303 board definition. It specifies PB9 for SDA which must be PB7. So you must either specify SCL, SDA and Reset in the U8x8 constructor explicitly or fix the board definition.
Also note that the LED is ON when HIGH (current F151 and F103 board definitions incorrectly indicate that LOW is ON which is not true).

2 Likes