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”.
It 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.
People – the subject is dead and buried, a year ago (not for the first time) the solution was imminent. It still doesnt work and probably never will. Life is too short. I am getting lots out of esp8266 + nano.
Except my test esp just died for no reason after working for many hours. Gets past apparent logon then reboots. Not a good day.
a reference for eventual future reconsidering this board, if i2c finally would work…
how to flash the usb bootloader, so no more serial adapter needed:
People have been talking about this for many, many months but same answer in the end.. I2c slave simply doesn’t work
there were good info from Squonk a few months ago, seems that they changed environment and the new one is actively development…
no updates since Squonk posts, 2 months ago… http://www.stm32duino.com/viewtopic.php?f=48&t=3612
There’s a fairly recent update from Frederic Pillon (who promised Skquonk that he’d have a look at it) at:- https://github.com/stm32duino/Arduino_Core_STM32/issues?utf8=%E2%9C%93&q=i2c+slave
He noted that the fix he’d put in had generated some compiler warnings. The follow-up on that was that adding a cast should get rid of the warnings without adversely affecting the integrity of the build.
So the status was changed to “fixed” 5 days ago and the change should be incorporated into the 1.4.0 release.
Probably this is a Wire Arduino IDE problem. If you use the development tools STMicroelectronics advises to use there is no such problem? But this seems a steep learning curve!
I am looking into using the BluePill because of the advanced capabilities now that I am running into limits of the Nano. At least I ordered a little development board and ST-Link and find out what is going on!
No it isn’t an IDE problem, more likely a hardware issue as no-one has resolved this. Getting I2c master running on this chip is a no-brainer but I2c slave.. .no. Wasting your time if you need i2c slave.
How do you understand this forum item then?
http://www.stm32duino.com/viewtopic.php?f=48&t=2127&sid=4d7c301cb8aa628f3db4326ff8366774&start=10
it’s old, look at squonk’s posts here… they took a new way to implement i2c…
just found on my twitter feed: https://twitter.com/cnoviello/status/782835498423312384
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.
I COULD… but the point of I2c is the ability to put multiple devices on the lines… wondering if I made a good choice here…hmm.
Maybe use HardWire?
https://github.com/leaflabs/libmaple/tree/master/libraries/Wire
Looks promising, but will it work as an I2C client?
http://www.stm32duino.com/viewtopic.php?t=53
No, but you see the point: it should not be too difficult to implement the slave’s onReceive() method using low-level stm32 API calls.
Well, not if you have some experience of using the STM32. I have scoured the web for this – thinking SOMEONE must’ve done it – nothing up to now.
It’s in German, but look here:
It should be pretty easy to wrap this code into an Arduino Wire class.
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.
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.
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.
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.
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.
‘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.
Yes, of course!
… But then your first STM32 stops working for some reason, and suddenly all your following STM32 devices stop responding altogether!
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
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….
not same processor, but could help?
https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https%3a%2f%2fmy%2est%2ecom%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fSTM32Discovery%2fI2C%20Slave%20Example&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=4751
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
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.
Oh and that is with no errors or warnings coming out of the Arduino IDE…. all working perfectly.
Hi Pete,
Some good tips here (you are using the “serial” instead of “stlink” option perhaps?)
N.B. The comments mention something about “Blue Pill” boot loader for getting USB to work (may need hardware mod?!?)
http://wiki.stm32duino.com/index.php?title=Blue_Pill
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.
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
ICYMI, new debian jessie for raspberry is available, with new graphical environment (Pixel), updated browser, node-red, and other stuff: https://www.raspberrypi.org/blog/introducing-pixel/
changelog: http://downloads.raspberrypi.org/raspbian/release_notes.txt
Ooooohhh.
lol 🙂
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…
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.
but the problem isn’t chromium… the problem are sites STILL using flash… the world has moved elsewhere, and every serious site has at least alternatives or has withdrawn flash…
and even bbc is moving away from flash, indeed…
http://www.bbc.co.uk/html5
http://www.bbc.com/news/technology-34399754
you can use a chrome extension to change browser user agent and use html5 instead of flash: https://unop.uk/how-to-watch-bbc-news-videos-on-a-desktop-without-flash/
Looks like you should upgrade the IDE
http://www.stm32duino.com/viewtopic.php?f=16&t=1426
I use the latest version 1.6.12 (with latest staging for ESP8266) and it works fine.
Also, the latest version allows you to use the default supplied pubsubclient (for esp8266 MQTT) which now seems very reliable and connection tolerant (I use it with Wifi Manager on an ESP8266)
Not that either – I am using 1.6.9 – my issue has nothing to do with the Arduino IDE – plugging the board into the PC – it is simply not being recognised as a valid serial port.
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
Does this help?
https://www.youtube.com/watch?v=-zwGnytGT8M
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.
this guy too says usb don’t work, and used external adapter: https://www.youtube.com/watch?v=krxeYUiBZNY
it seems that the usb connector is only for power, looking at many videos on youtube… they use external programmer:
https://www.youtube.com/watch?v=G_RF0a0hrak
while this guy has a different procedure…
https://www.youtube.com/watch?v=0jdJp3TQuJY
or try this, found on a russian video: https://www.youtube.com/watch?v=oDoavXrQdEg
http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-utilities/stsw-stm32102.html
Thanks will look through now. I need to turn that moderation stuff off except for new visitors.
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…
there’s a comment in moderation right up here, maybe with stuff useful… sorry for hijacking the post with latest jessie stuff, let’s talk about that elsewhere 😉
so, almost everywhere i found that the usb is only for power, and feeds a 3.3 ldo… so, other links:
https://wiki.kewl.org/dokuwiki/boards:vcc-gnd
and searching with the other name of this board (maple mini):
http://www.rogerclark.net/stm32f103-and-maple-maple-mini-with-arduino-1-5-x-ide/
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Installation
here talks about the reset: https://github.com/rogerclarkmelbourne/STM32duino-bootloader
http://www.phreakmonkey.com/2015/08/programming-generic-stm32f103c-board-in.html
http://jeelabs.org/article/1613a/
Thanks for those links – up and running.
Got the USB jumpers on? (http://cxem.net/ckfinder/userfiles/comments/50289_stm32f103c8%20User%20manual.pdf)
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??