Arduino STM32

Having decided I needed a more powerful generic peripheral board than the Arduino, I sent off for some STM32 boards to China – they got lost in the post. Meantime my friend Aidan sent me a nice little black board marked “JM ELECTRONIC STM32F10XC8 SYSTEM BOARD”.

STM32It came complete with miniUSB connector so I plugged it in.  A red light came on and stayed on – and a green light flashed on and off regularly. Always a good start.

I found this link… which suggested I install Arduino Zero into my existing Arduino 1.6.9 IDE setup. Life is never that simple – the nearest I could find in the Arduino boards manager was “Arduino SAMD Boards” – which mentioned Arduino/Genuino Zero.  I installed that.

From here I grabbed the Arduino_STM32 directory from that link to put in \users\pete\my documents\arduino\hardware folder… I’m familiar with this idea as I have my mighty-1284p folder in there already to program the 1284p chips – a powerful more-or-less Arduino compatible chip which sadly never really took off.

I closed the Arduino IDE and re-opened… lovely – except – Windows 10 does not recognise the USB device. I loaded the drivers to no avail… it simply was not having the board yet I had no reason to suspect there was anything wrong with the board itself.

MrShark in here did his best to convince me that the USB connector was not for serial – some places suggested it was – anyway – I decided to assume he was correct on this and instead of using the USB connector, used one of the end connectors which has ground, 3v3, serial in and serial out – attaching them to my normal FTDI.

This PDF document got me part of the way because the board featured within is exactly the same as the board I have (courtesy of Aidan Ruff who bought it from AliExpress – mine is still floating about in the post, is slimmer and half the price – generally it looks like we are talking about 64k of FLASH and 20K of RAM and a BOATLOAD of peripherals).  The connectors indicate that there are various ways to boot  the board. Interestingly you can boot from FLASH, or boot into programming mode or boot from RAM (that’s interesting).  I selected boot into programming mode and sure enough – reset the board, send the program instruction – voila – one programmed board – no warnings, no error messages.

Elsewhere I read that there are 15 pins that can be programmed as 16-bit PWM – a step up from the Arduino. Sure enough I tested this out in the examples – the pins were numbered 0,1,2,3 etc and these equate to A0, A1, A2 etc with 16 being B0 etc.  I tested all 15 pins – and they all do PWM!!! (0, 1, 2, 3, 5, 6, 7, 8, 9, 11, 12, 14, 24, 27, and 28). The instructions in this link refer to the “Maple” – so it may be this is a good source to get started with. The only real difference up to now between this and the Arduino apart from superior PWM is the need to actually set the pin up for this – i.e.

pinMode(9, PWM);

This entry will evolve as I learn more – assuming I can get this board to be an I2c slave it could well be quiet useful.

Facebooktwittergoogle_pluspinterestlinkedin

46 thoughts on “Arduino STM32

    1. That is INDEED the right board. I had all 3 jumpers on... but in the photo in the link you sent - they had them all off - so I took them all off. Same result... the last USB device you connected to this computer malfunctioned and Windows is not having it...

      The picture you sent actually had NO links in - are you using this - and in which case which links do you have connected??

    1. Sadly no - I've managed to get all of that done - the problem is - the serial port is not showing up and Windows is making very disappointed noises when I plug in the board. Driver issue I THINK. I tried installing the drivers that came with that code - no difference.

        1. He is hard work 🙂 but the point is made- I just need to figure out what to do with all these connectors.... and he's using serial but I don't see what he's using as a reset - normally you have some kind of trick to force the unit into programming mode...

      1. peter, but the device appears in device management applet in windows, at least? even with yellow triangle? if yes, go in properties, details, first combo, hardware ID, and do a search for the full value you get there (the longest one, if multiple)... or attach it to a raspberry or other linux and do a: sudo lsusb
        to see it's device id

      1. your beloved vnc is now embedded, too, and your hated epiphany is gone, for chromium instead, with hardware accelerated support... and wifi and bt can be completely disabled to reduce power consumption, if not used...

        1. As I already have VNC - I'm updating everything but that - on a test Pi first then on the main Pi - when they both work I'll remote update the Pi back in the UK. Let's move this discussion to a new entry. I'll update the blog soon with a subject Raspberry Pi Debian or something. Right now I need to get a driver running for that SAM board.

          Ok, test Pi 2 updated - leaving tightVNC in place. Initial reaction - upgrade worked out of the box - very good!! Also installed Chromium which is awful - go to the BBC site and the same rubbish "install Flash" - it is WAY beyond time that Linux got to grips with the fact that anyone using a browser is likely to want to look at videos of some sort. Predictably - right click to use this plugin - FAIL.

  1. Pete, you probably already saw this, but just in case - from the STM32duino FAQ:

    Windows specific questions

    Q. When I plug in my board to the USB on my PC, it says device not recognized
    A.If you have a brand new board, other than a Maple, or Maple mini, the chances are that your board does not have a bootloader, or any other firmware installed on it at all. In this case you need to "flash" the Stm32duino bootloader onto your board.

    Q. I installed the bootloader, but Windows says it can't find a driver for the board?
    A. You need to install the special Windows driver using the batch file in /drivers/win in the files you downloaded from GitHub

    http://www.stm32duino.com/viewtopic.php?f=2&t=873

  2. Ok, it's late at night here in Spain - but a quick report - thanks to one of the many links from Mr Shark... two things - the USB argument appears correct - can't program from that - so I hooked 3v3, ground, serial in and out to the edge connector. Nothing. Then I noted one combination of the boot links would not result in the demo flasher working. I tried the Arduino IDE on FTDI - nothing - on a whim I tried SERIAL..... and voila - a test program flashing a light on an arbitrary port bit - works a treat.

    Well, it's a start. I'll post pics later with the actual model of STM32 I'm using (not the same as the options on the Arduino IDE but I picked one at random) and the settings. Today a flashing light, tomorrow? Already discovered FIFTEEN outputs which can be a 16-BIT PWM!! Smooth as you like!!!

    Good night all.

      1. Thanks Pete - and everyone - I am blowing the board serially - got PWM working, tested 15 PWM outputs.... I'm sure other stuff works - worried about comments out there about difficulties with i2c slave on this chip.

  3. Peter, sorry for the too many links i posted... i'm prone to have tons of chrome tabs open while i do search, and posted the ones i thought could help you... i'm not as advanced to check myself, nor i have a board to test myself, too

  4. The STM32F103 is a great part, cheap, fast, DMA, lots of good stuff.

    If you get yourself a Bluepill (the Maple Mini clone), the on board USB micro connector (PA11,PA12) works a treat for uploading from the Arduino IDE.

    The boards don't come preloaded with the USB bootloader, just a serial bootloader in ROM. It's fairly easy to put the USB bootloader on using the serial bootloader though I found the flash had to be unlocked first.

    The instructions for installing the USB bootloader:

    How to use a USB to serial converter (CH340 or whatever) to load the USB bootloader

    1) Connect: CH340 RX to Bluepill PA9, CH340 TX to Bluepill PA10, Ground to Ground.
    Note: my CH340 board is 3v3 signal levels, not sure if the STM32f103 IO is 5v tol, it could be, I think some pins are 5v on this ppart.

    2) Command Prompt
    3) cd Documents\Arduino\hardware\Arduino_STM32\tools\win
    4) Move top jumper over (BOOT0) - then hit reset or power cycle

    5) You might have to UNLOCK the flash FIRST with:
    stm32flash.exe -k COM12

    6) Now flash with:
    stm32flash.exe -w ..\..\STM32duino-bootloader\STM32F1\binaries\generic_boot20_pc13.bin COM12

    7) Revert jumper (BOOT0) and reset or power cycle
    8) Device mananger will read libusb-win32 devices > Maple DFU
    9) Load an Arduino sketch with serial and port will show

    1. Hi there

      Well as mine is working - I'm guessing the bootloader must be in - I'm flashing programs via serial.

      I have 3 Bluepills or something that looks like them on the way - but they're lost in the post - hence using this alternative one... Your info will come in handy when they arrive no doubt. Thanks for that.

      I'm more worried that I cannot find anyone who has managed in the Arduino environment to get I2c slave working properly on these devices - some say the code is software bit-banged, others claim the hardware is faulty etc....

  5. I2C for STM32duino doesn't look good. Perhaps some day it will work.

    Could you use serial (UART)?

    Perhaps make your own 1 wire protocol? You're not passing much data, just commands.

      1. I do like your line of thinking, the STM32 devices are cheap and much more capable than AVRs. Most Teensies can do I2C, but the $11+ cost may be a deal killer.

        Regarding serial and multiple devices would this work? From ESP8266 connect TX to RX of first STM32, then connect TX of first STM32 to RX of second STM32. To command the first STM32 the ESP8266 sends a "0" address in the header (first byte?), the first STM32 sees the "0" and knows the packet is for it and executes the command(s). To command the second STM32, the ESP8266 uses address "1" which the first STM32 receives then subtracts 1 (now it's "0") and passes the packet to the next STM32 which sees the "0" and knows the packet is for it.

        1. Yes $11 IS a killer, nearly 10x the STM32 price 😉

          Instead of UART daisy-chaining and besides obvious electrical reasons, who said you can't bus connect UART signals? If there is only one master or if everybody is performing listen-before-talk and collision-detection by listening what it just sent, you have a much safer topology in case a node crashes...

          Just add differential buffers, and you are up to RS485. With CAT5 cables, RS485 may achieve data rates in excess of 50Mbps over cable lengths of hundreds of meters, and without repeaters.

          Or wait for the ESP32 and use the CAN bus.

        2. Funny you should say that, I have two TEENSY 3.1 devices in front of me... I was just about to add Teensy support to the Arduino environment to give it a go - turns out that the normal paltry 8-bit PWM support on those boards can actually ramp up to 16 bit PWM. As you say the cost kind of kills off any serious use as a peripheral unless the Chinese have a board using the same chip.

        3. Because I use serial output for general debugging I would not keep it that simple - however I do have an EXTEND command...so that I can send out instructions to an external device.... a little parsing on the STM might then allow sending stuff to it via serial.... I've no mechanism for accepting stuff BACK however right now.... but that's worth a thought... one could add in an address so that a package coming in would be passed straight out if not for a given unit - again this also makes sending return info a little awkward.

          1. DON'T daisy-chain UARTs: in case of a single node failure, the whole chain is down!

            Better use UARTs as a bus, as I said above: provided no 2 devices are talking at the same time, it is fine.

            Unless a downed device keeps the UART RX and/orTX low, the whole system keeps running.

        4. 'Regarding serial and multiple devices would this work? From ESP8266 connect TX to RX of first STM32, then connect TX of first STM32 to RX of second STM32.'

          Cor, my first LAN was Clearway. It was a RS232 ring that worked just like that. Used it for printer sharing and VT100 terminal connections to microVaxes running a specially ported version of BSD.

Leave a Reply

Your email address will not be published. Required fields are marked *