STM32 "for the rest of us"

Problems w/ OneWire and DS18B20

UPDATE: independently confirm to be an issue with Maple & Maple Mini clones - but not an issue on generic boards. This has been placed on the issues list and will be prioritized for research and correction. I'll report here when corrected.

Response to @turkogluky: link

Summary: the current version of OneWire appears to freeze the Maple uC.

Test procedure: I used a Nano to prove the DS18B20 was working; the 4.7K pull-up was required at 5V.

I used a new STM32 Maple Mini clone tested with my blink-count script to confirm the Maple Mini was fully functional.

When I went to the \Documents\Arduino\hardware\STM32\STM32F1\libraries\OneWire\examples\DS18x20_Temperature script, it would not compile on my Windows 8.1 box.

The error was traced to the fact that for some crazy reason, the OneWire lib was being pulled from: \Documents\Arduino\libraries\OneWire\ and not from \Documents\Arduino\hardware\STM32\STM32F1\libraries\OneWire\

I fixed that by including the entire path:

include "\Documents\Arduino\hardware\STM32\STM32F1\libraries\OneWire\OneWire.h"

The program compiled: (1.6.1 shipping)

Sketch uses 15,388 bytes (14%) of program storage space. Maximum is 108,000 bytes.
Global variables use 4,528 bytes of dynamic memory.

HOWEVER: The instantiation of OneWire causes the uC to either freeze or appear to freeze. Pressing RESET goes into DFU but when the user program starts, nothing. Worst, the COMn port does not enumerate on Windows, so no debug output.

I changed Serial. to Serial1. and got a clean compile, but again, OneWire freezes the uC.

Ray

Just a note that the Beestore Maple Mini clone (whose PCB is a different layout than the original or Baite version) also works fine with the STM32 repo. Have had a couple for a while but never got around to trying them until this week, when I made a big push to get a fresh 1.6.1 install running all of the STM32/core13/TinyCore1/esp8266 cores.

Just a quick update

OneWire only seems to work on generic STM32 boards

I have posted a fix to the main thread, but it involves a slight difference in the way the OneWire class is initialised - I won't bore you with the technical details

There were various issues with OneWire, so it has now been renamed to OneWireSTM

See the other thread for the technical details, or just download the relevant files and enjoy :wink:

hi, is there any tutorial how to use ST-Link with arduinoIDE to program STM32? i can do it by usb, but if want to program single STM32 chip on custom board don't know how to set it

Stm32 to flash. Board type had STLink option on windows

There are no tutorials for this on the arduino but there may be general tutorials for stm32 in general e.g. On YouTube

I've checked YT, still didn't manage, there were some programming stuff about discovery boards and different than arduinoIDE program uploaders, some ST-Link tools, I have an option on my IDE for upload method as ST-Link, but it shown me a message that it can't connect into st-link device - however windows seen st-link in device manager

bigplik: I've checked YT, still didn't manage, there were some programming stuff about discovery boards and different than arduinoIDE program uploaders, some ST-Link tools, I have an option on my IDE for upload method as ST-Link, but it shown me a message that it can't connect into st-link device - however windows seen st-link in device manager

The original implementation of the STM32 core project was directed toward the Maple and the Maple Mini clones. The project grew to address a larger population of STM32 boards based on the STM32F103.

The project was never intended to be a "newbie" project as a replacement for the Arduino 8-bit UNO, Mini, Nano, etc. It was intended for more experienced experimenters who for some reason had outgrown the 8-bit capacity but did not want to rush to the Due; that is, an inexpensive alternative based on easy to obtain Chinese clones of the Maple and Maple Mini.

Some of the boards (Maple Mini) support USB programming and connectivity much the same way that the ProMicro (32U4) does - it enumerates itself as a COMx port under the OS. With Windows, this requires drivers to be installed; instructions are in the Github wiki.

Other development boards or boards that do not enumerate to a COMx port are usually programmed using ST-Link which requires that you purchase a programming device that goes into the PC USB port and connects to the ST-Link header on the board. You can read through the long thread on the devices ordered and that worked (or did not work well.) I use Windows can cannot recommend one.

This is very important and I am going to repeat this again: The STM32 core is not a beginner's project and while the core is working there are some serious issues documented on the github wiki. Just as the issue with OneWire did not appear until a few days ago, I am sure there are other issues which will need work-arounds and fixes. BUT, this is a hobby project and there is no guarantee that compatibility will occur - if you order an STM32 board and utilize the core, you need to know that you are on your own and the core is always in flux - as of this week, a few commands from LeafLabs were removed to align more toward the Arduino commands.

Many AVR 3rd party libraries will not work unchanged - consider this a warning. If you do not understand how to hack a library or are not competent to look into a Due or Teensy3.1 library and ferret the logic - avoid the library. You can check here on github to see if the core team has provided a replacement: Ported-Working libraries for the STM32 (all functions may not work.)

When things are found that do not work (not libraries, basic Arduino commands) someone will hopefully have the hardware to validate the issue and the issue will be placed on the github wiki. Roger will address the priority and determine if a workaround or fix will be appropriate - OR, the issue may simply be documented and left the way it is... depending on the impact. There are no guarantees.

Ray My Projects

Just to clarify

The STM32F1/libraries folder now contains a new folder called OneWireSTM

I have removed the old OneWire folder, as it was not getting found by the IDE (and I don't have time to debug the IDE)

Examples for OneWireSTM are in the examples folder

e.g.

hardware\Arduino_STM32\STM32F1\libraries\OneWireSTM\examples\DS18x20_Temperature

The updated examples reference the new folder name and new header name OneWireSTM.h

I have compiled and tested the DS18B20 example using pin 10 on my Maple board and it worked fine. I also tested on pin 15 and it was also OK.

Hi.

I try to make a "Hello World" with STM32 and I2C_LCD, but it dont work.

#include  
#include 

// Set the LCD address to 0x20 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x20, 16, 2);

void setup()
{
    // initialize the LCD
    lcd.begin();
    // Turn on the blacklight and print a message.
    lcd.backlight();
}

void loop()
{
  lcd.print("Hello, world!");
  delay(1000);
}

|500x375

The address is confirmed with BusPirate and I can se the signal with my oscilloscope.

The display works with Arduino board.

It looks like the init is going wrong, as I can see flicker every time I send the string.

STM32F103RC and IDE ver. 1.6.3

Interesting

I've not tested this.

I think the LCD library was the one produced by LeafLabs and I'm not sure if its ever been updated :-(

If you have a github account, can you post this as an issue

Guys,

I know some people like to see things visually in a video etc.

So I"ve done an update to my previous video, which describes how to get STM32 working in IDE 1.6.2 or newer

See https://www.youtube.com/watch?v=TePglhSkghg&feature=youtu.be

(Moderators. Sorry for cross posting, but there are 2 different audiences for this project)

Unfortunately I don't have one of those displays.

I have a parallel version but not the I2C version

This issue could be I2C speed, its defaulted to FAST in the Wire lib as this works with most things and gives better speed.

But the speed is faster than the AVR boards (i.e AVR uses 100Khz and I think the STM32 default is more like 250kbps) so this may be the issue.

Its probably worth getting hold of the I2C Scanner from the "Arduino Playground" (written by Nick Gammon) and seeing if the display ID's show up on a scan.

To see if its I2C speed issue, look in

hardware\Arduino_STM32\STM32F1\libraries\Wire\Wire.cpp on the line at the bottom that reads

TwoWire Wire(PB6, PB7, SOFT_FAST);

and change it to

TwoWire Wire(PB6, PB7, SOFT_STANDARD);

which would bring the speed down to 100khz like the AVR boards.

I'm not sure if the version that LeafLabs shipped with the IDE (I.e the one we have) is any different from the normal one.

Looking online, the current version is a lot different from the one we have e.g. the new one can be downloaded from here

http://hmario.home.xs4all.nl/arduino/LiquidCrystal_I2C/LiquidCrystal_I2C.zip

I'd suggest that you try using the latest version instead of the possibly old version we have in the repo

I'll also look at the price of that display, if its just a few dollars I'll order one

Can you confirm if the board you have is this one ? http://www.ebay.com.au/itm/16x2-Serial-IIC-I2C-TWI-5V-1602-LCD-Module-Display-Arduino-UNO-R3-MEGA2560-New-/261819816573?pt=LH_DefaultDomain_15&hash=item3cf5ad5a7d

That board has worked for me with the FMalpartida I2C library... There were some issues with the constructor and varying connections between the PCF8574 and the display. There is a most comprehensive thread in the display section referring to this issue.. I have a level shifter and a 3,3/5V boost mode switcher that I plan to assemble for a Teensy 3,1 next week. I plan to use a 4 X 20 LCD with it.. I just need to get my desk cleared first. It should work well as I've used that library many times before...

Doc

rogerClark: Can you confirm if the board you have is this one ?

More like this one: http://www.ebay.com/itm/Module-Display-Character-LCD-1602-16x2-HD44780-Controller-Yellow-Green-Backlight-/350662659597

...soldered together with this one: http://www.ebay.com/itm/Board-Module-Port-IIC-I2C-TWI-SP-I-Serial-Interface-Arduino-1602-LCD-m2-/131331658861

This is a 5V display - it runs fine on 3.3V but then the contrast voltage must be -0.9V so I run it on 5V with scl/sda pull-up to 3.3V

rogerClark: To see if its I2C speed issue, look in

hardware\Arduino_STM32\STM32F1\libraries\Wire\Wire.cpp on the line at the bottom that reads

TwoWire Wire(PB6, PB7, SOFT_FAST);

and change it to

TwoWire Wire(PB6, PB7, SOFT_STANDARD);

which would bring the speed down to 100khz like the AVR boards.

No luck with this.

Looking online, the current version is a lot different from the one we have e.g. the new one can be downloaded from here

http://hmario.home.xs4all.nl/arduino/LiquidCrystal_I2C/LiquidCrystal_I2C.zip

I'd suggest that you try using the latest version instead of the possibly old version we have in the repo

With this library it works fine - thank you. 8)

Cool

OK. So can you confirm I should remove the LCD_I2C library that is in the current files and replace with the one I linked to ?

Thanks

Roger

@Sunspot

Re: Generic STM32F103C8 board

I have started work on the a generic STM32F103C board type, rather than internally use the "variant" code for the Maple mini

The only difference you should see if you use this, is that pin PB9 is now available. It is not available on Maple mini because its use internally to reset the USB bus

This is somewhat of a work in process, so it would be good if you could give it a try and see if it works for you. Because although the changes I made are not technically very difficult, there is a lot of manual searching and replacing of pin names / numbers.

PS.

I presume you are using the STM32 pin names e.g PA5 - which I feel is definitely the correct way to do things.

Roger I will try but in a couple of days - pin names e.g PA5 work.

The large generic board blinks OK as delivered - it has space for a clock Xtal but none fitted - no real advantage over your small generic board - or the Mini I guess.

3 Maple Mini clones (below £4) arrived from 3 vendors. All blink and none show rework.

Using the Maple IDE on iMac I can program them via USB. I have loaded your USB drivers but do not see the Minis - not sure how to activate the drivers. Guess I can use serial like for generic but will wipe the USB boot SW?

This winter hobby is holding back spring jobs - OK in Oz!!