Author Topic: STM32F103 any good?  (Read 57752 times)

0 Members and 1 Guest are viewing this topic.

Offline MuxrTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
STM32F103 any good?
« on: April 22, 2015, 04:17:09 am »
I've done some AVR development in the past. My background is software engineering so I don't mind learning a new language or environment.

But basically I've been shopping around for an MCU to migrate to after using 8Bit AVRs. I was mainly looking for cheap MCUs in case I decide I want to mass produce one of my projects, so the price is really important.

I was shocked with how cheap these (STM32) F103s are. For instance one of my projects is a clock and I have a need for an RTC module but this STM32 comes with a built in RTC. It's actually kind of mind boggling how much more advanced and how many more features F103 packs for the same price as an AVR Atmega328.

I mean you get: 75Mhz, 32Bit arch, 64Kb Flash, 20Kb SRAM, 2x12Bit ADC, bunch of interfaces, USB2.0, 7-channel DMA

I ordered a few of these $4 boards to play with: http://www.ebay.com/itm/311156408508?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

There is an open source Arduino toolchain: https://github.com/rogerclarkmelbourne/Arduino_STM32  It's pretty experimental though.

So I guess the question I have is, what's the catch? Anyone have experience with STM32 Cortex M3 F10x controllers, are they any good? And where should I begin in terms of software tools to program these guys? (preferably OS X / Linux toolchains).
 

Offline HackedFridgeMagnet

  • Super Contributor
  • ***
  • Posts: 2028
  • Country: au
Re: STM32F103 any good?
« Reply #1 on: April 22, 2015, 04:40:22 am »
It's a great step forward to get out of the Arduino ide.
I use eclipse with the cdt plugin and gcc and openocd(i think that is its name) for the debugger.

There is a fair bit of effort to set it up if you haven't done it before.
But there is plenty of support around and you wont look back.

the best way to start coming from arduino is probably the nucleo boards and some intro (limited) ide that should come with a board.
 

Offline chickenHeadKnob

  • Super Contributor
  • ***
  • Posts: 1055
  • Country: ca
Re: STM32F103 any good?
« Reply #2 on: April 22, 2015, 05:08:00 am »
The stm32f103 is one of the older cortex m3 processors and for historical reasons unknown to me became very popular in china some years ago. That means you can find many ebay offerings at well below digi-key pricing so they are great value for the money. If you want cortex m4F (hardware floating point) some members of the stm32f3xx can be found cheap from north American disti's, but not as cheap as the 103. The newer stm chips have better (and more) timers and other peripherals.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F103 any good?
« Reply #3 on: April 22, 2015, 05:34:28 am »
The RTC in the F103 is only a 32 bit counter and does not provide calendar features. And usually the inernal 32Khz oscillator does not run on Vbat, something to be aware of. (I'm not sure in this chip)
The F103 can only run 36 MHz from internal oscillator. For 72 MHz you'd need an external source. (You'd need it USB anyways)
 

Offline neslekkim

  • Super Contributor
  • ***
  • Posts: 1305
  • Country: no
Re: STM32F103 any good?
« Reply #4 on: April 22, 2015, 05:37:33 am »
Look at this thread: https://www.eevblog.com/forum/microcontrollers/stm32-ghetto-style/
and all the spinoff threads..
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: STM32F103 any good?
« Reply #5 on: April 22, 2015, 05:57:52 am »
The I2C peripheral is badly designed, otherwise it's a pretty straightforward chip.

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9930
  • Country: nz
Re: STM32F103 any good?
« Reply #6 on: April 22, 2015, 06:42:05 am »
Yep f103 is good, be prepared to learn a standard peripheral library as opposed to fiddling with the raw registers as you do on AVR.
Its much more feature advanced so you really need a peripheral library or it takes ages to get stuff working.

Also the AVR registers are as dream to code, everything is layed out in a way that makes sense. Stm32 not so much, but with the library you don't need to go  down to that level anyway.

Be aware there are many things in stm32 you need to enable that were on by default in AVR. Clocks for various parts of the chip and stuff
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline muvideo

  • Frequent Contributor
  • **
  • Posts: 418
  • Country: it
Re: STM32F103 any good?
« Reply #7 on: April 22, 2015, 07:43:50 am »
The RTC in the F103 is only a 32 bit counter and does not provide calendar features. And usually the inernal 32Khz oscillator does not run on Vbat, something to be aware of. (I'm not sure in this chip)
The F103 can only run 36 MHz from internal oscillator. For 72 MHz you'd need an external source. (You'd need it USB anyways)

In the F103 the RTC runs off Vbat, internal oscillator can be used to clock the chip up to 64MHz.
Fabio Eboli.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F103 any good?
« Reply #8 on: April 22, 2015, 08:01:16 am »
In the F103 the RTC runs off Vbat, internal oscillator can be used to clock the chip up to 64MHz.
Yes. And that's where you need to read carefully. There are multiple series sharing the documentation and number STM32F1xxxx. Very ambiguous.
Connectivity line devices can only go up to 36 MHz and Low-, medium-, high- and XL-density series can go up to 64 MHz from hsi.
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7369
  • Country: nl
  • Current job: ATEX product design
Re: STM32F103 any good?
« Reply #9 on: April 22, 2015, 08:11:57 am »
Yes the F103 is one of my standard components to use. It is good, well designed. I think the only time when it was a letdown, when we realized that the USB and the CAN cannot work concurrently.
But you need to be aware that only the smaller F103s are the ones I can recommend. If you need more than the 20K SRAM and 128K flash, there are much better choices even in the F300 and F400 series.
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1672
  • Country: pl
  • Troll Cave Electronics!
Re: STM32F103 any good?
« Reply #10 on: April 22, 2015, 10:40:01 am »
Yes the F103 is one of my standard components to use

Ditto. I tend to standarize on STM32F030F4 for small stuff, STM32F103 for medium and STM32F407 when in need of serious processing power.

As for IDE, I recommend CoIDE from CooCox. For me it is practically problem-free, and all the external setup you need to do is to install the arm-gcc and provide the path to it in IDE. It's totally free (no limitations whatsoever) and in general supports most of ST's Cortex uCs
I love the smell of FR4 in the morning!
 

Offline daybyter

  • Frequent Contributor
  • **
  • Posts: 397
  • Country: de
Re: STM32F103 any good?
« Reply #11 on: April 22, 2015, 11:21:59 am »
This board does not support external RAM, right? (Ordered one, too.)
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #12 on: April 22, 2015, 11:38:39 am »
These F1/F2/L1 chips from STM have very similar peripherals.
The F103 is a faster and feature-rich version of F102, although F103 is cheaper in retail, it may not be in volume.

For development, I'd suggest picking a 512kB flash/64kB SRAM in LQFP100 or higher, for release you can pick anything that barely matches the requirements (down to 16kB QFN36). Mind these 72MHz chips are optimized for speed so jumping from coremark=11 for AVR8 to coremark=108 of F103 may not be what you expect (GCC).

Now the differences..
These chips use 3,3V nominal voltage, some IOs can operate up to Vcc+4V, around 8V max in open drain mode (I think they refer those as "5V tolerant"). This "feature" means that internally these 8V IOs do not have the upper clamping diodes. So, if you apply 12V through 4k7 resistor to an IO of AVR8 then nothing spectacular happens, IO is driven up to Vcc+0,7V and upper clamping diode limits the voltage.
The problem is that same experiment should fry the 8V IO on STM32.
Now, not all STM32 IOs are 8V compatible. Some are just regular IOs with both clamping diodes. Here injecting current won't damage the chip "if you limit the current to the one specified in maximal ratings of course " but can ruin ADC readings of the uC.

As of the toolchains, if you pick the IDE with wizarding (like uVision or CooIDE) then the setup is similar to the one with AVRStudio. Just name the project and:
Code: [Select]
int main void(){..... return 0;}However, if you decide to pick a bare metal route, then it is same as with bare metal AVR8 and you have to provide your own linker, startup code, IRQs etc. If you never wrote startup code and/or linker scirpt for AVR8 then most likely writing one for STM32 is going to discourage you (even configuring a clock tree can ruin your day).
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1672
  • Country: pl
  • Troll Cave Electronics!
Re: STM32F103 any good?
« Reply #13 on: April 22, 2015, 11:48:37 am »
Another thing: as with almost every ARM uC you need to remember to enable the clock to a peripheral before you can actually use it.
I love the smell of FR4 in the morning!
 

Offline MuxrTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
Re: STM32F103 any good?
« Reply #14 on: April 22, 2015, 02:21:23 pm »
Thanks for the replies guys, awesome info!

Another thing: as with almost every ARM uC you need to remember to enable the clock to a peripheral before you can actually use it.
Yes I read that, it seems to be ARM's way of making you think of power utilization I believe.

Found their peripheral library as well for F103, STs website is kind of a mess. Found this index of F103 stuff if anyone else happens to be looking for it: http://stm32.eeelec.com/html/STM32F1%20resources.htm  3.5.0 seems to be the latest version of the standard peripheral library.

Browsed around the source, seems pretty straight forward.
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1672
  • Country: pl
  • Troll Cave Electronics!
Re: STM32F103 any good?
« Reply #15 on: April 22, 2015, 02:44:56 pm »
It's not how ARM does it. It's how ST, NXP,  Atmel and such do it. ARM only provides the core,  all peripherals are of particular vendor's design.
I love the smell of FR4 in the morning!
 

Offline MuxrTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
Re: STM32F103 any good?
« Reply #16 on: April 22, 2015, 02:47:26 pm »
It's not how ARM does it. It's how ST, NXP,  Atmel and such do it. ARM only provides the core,  all peripherals are of particular vendor's design.
I stand corrected. Although they all seem to be doing things in a similar fashion, perhaps something mandated by ARM via CMSIS?
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1672
  • Country: pl
  • Troll Cave Electronics!
Re: STM32F103 any good?
« Reply #17 on: April 22, 2015, 03:04:14 pm »
I don't know. If I had to guess,  my first bet would be on the fact,  that those chips are loaded with many modules and features,  each of which draws some current and not all of them can be used at the same time, so if they were all turned on at all times,  the power consumption figure would be much higher. Since nowadays there is almost always some pressure on reducing the power consumption of a product, this is a really useful feature. Lower power is not only longer battery life but also smaller regulators,  less filtering capacitance lower transient currents when switching and so on.
I love the smell of FR4 in the morning!
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4414
  • Country: dk
Re: STM32F103 any good?
« Reply #18 on: April 22, 2015, 04:16:05 pm »
I don't know. If I had to guess,  my first bet would be on the fact,  that those chips are loaded with many modules and features,  each of which draws some current and not all of them can be used at the same time, so if they were all turned on at all times,  the power consumption figure would be much higher. Since nowadays there is almost always some pressure on reducing the power consumption of a product, this is a really useful feature. Lower power is not only longer battery life but also smaller regulators,  less filtering capacitance lower transient currents when switching and so on.

it also mean a single part can cover a lot more applications. Compared to the size of ram and flash the peripherals are tiny so it makes sense to add as many as you can think of and just turn them on and off as needed

 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F103 any good?
« Reply #19 on: April 22, 2015, 05:54:52 pm »
They typically put the bare die full of stuff they disable later one. Such as extra ram, flash, timers, or maybe even entire Cortex M0's. Such as the lpc43 en 18.
Because if you compare the LPC18 and LPC43 addresses, they are remarkably similar. Just otp't the configuration differently. This is nice, because you don't need to bake many different chips. Just a few, and later on you decide what configuration you'll give them.

Obviously, enabling everything will be problematic with power consumption, and thus temperature specs.

I'm currently working on an small 3xAAA powered proprietary remote control. The STM32F1 XL series (with the 1 MB flash) is capable of doing that.
But it seems just a little bit underpowered for doing a 320x240 spi-lcd, the fancy way. Sure it can draw lines and stuff (using STemwin) but it's a bit slow-ish. I was unable to get the fancy features of emwin working. Maybe because a copy of the LCD does not fit in ram. I was unaware of the "feature" that USB and CAN use the same RAM block. It was nice if one of them was capable of being remapped. This is one of things you discover if you inherit a project.
The power consumption of the STM, with life-support, in this application is about 20mA (3.3V). When I unplug the LCD, obviously.
« Last Edit: April 22, 2015, 06:08:49 pm by Jeroen3 »
 

Offline MuxrTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
Re: STM32F103 any good?
« Reply #20 on: April 22, 2015, 06:24:18 pm »
Yeah, I was reading the other Ghetto STM32 thread while mostly about the smaller F0s Dannyf actually tested F103 going beyond the Flash 64kb boundary specified in the spec sheet.

Apparently they can have usable 128kb. https://www.eevblog.com/forum/microcontrollers/stm32-ghetto-style/msg516439/#msg516439
« Last Edit: April 22, 2015, 06:29:20 pm by Muxr »
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F103 any good?
« Reply #21 on: April 22, 2015, 06:56:07 pm »
On the St forums, Clive1 actually confirmed this for 407 parts.
Quote
The ones above the 512KB threshold (>= 0x08080000) have not been tested. The 405/407 parts typically have the same 1MB dies. There is only a single bank of flash.
Just remember that although the memory is available, there are no guaranteed specifications on those parts of flash.
 

Offline MuxrTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
Re: STM32F103 any good?
« Reply #22 on: April 22, 2015, 10:03:59 pm »
On the St forums, Clive1 actually confirmed this for 407 parts.
Quote
The ones above the 512KB threshold (>= 0x08080000) have not been tested. The 405/407 parts typically have the same 1MB dies. There is only a single bank of flash.
Just remember that although the memory is available, there are no guaranteed specifications on those parts of flash.
Yeah no telling if extra Flash is faulty or a higher grade part bined for lower spec demand.
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1672
  • Country: pl
  • Troll Cave Electronics!
Re: STM32F103 any good?
« Reply #23 on: April 22, 2015, 10:04:53 pm »
Another thing that is different between ARM uCs and AVR/PIC/MCP430. A lot of time-critical registers have different address for disabling and enabling. For example for a gpio port in STM you have a BSRR (bit set reset register) and BRR (bit reset register). When you write 1 to BSRR on position 0 you set gpio0 high, is you write 1 into BRR on position zero, you set gpio0 to low. There is obviously also traditional way via ODR (output data register) where you write 1 or 0 and gpio assumes this logic state.

Another useful thing is bit-banding, which is a mechanism available in CM3 and CM4. It mans that particular registers have an alias somewhere in the memory for every bit in that register which allows truly atomic modification of registers (no read-modify-write problems). Read up on bit-banding.
I love the smell of FR4 in the morning!
 

Offline MuxrTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
Re: STM32F103 any good?
« Reply #24 on: April 22, 2015, 11:16:05 pm »
That's pretty slick, this article explains it pretty well: http://spin.atomicobject.com/2013/02/08/bit-banding/
 

Offline HackedFridgeMagnet

  • Super Contributor
  • ***
  • Posts: 2028
  • Country: au
Re: STM32F103 any good?
« Reply #25 on: April 23, 2015, 12:41:28 am »
That's pretty slick, this article explains it pretty well: http://spin.atomicobject.com/2013/02/08/bit-banding/
IMO that article just confuses me.
the link on the ARM website doesn't help much either.
Then the example? I should submit this code to www.thedailywtf.com Why the mailbox analogy?? for something supposedly atomic. Is it like an example of a single bit mailbox between processes?
Quote
#define BITBAND_SRAM_REF 0x20000000#define BITBAND_SRAM_BASE 0x22000000#define BITBAND_SRAM(a,b) ((BITBAND_SRAM_BASE + (a-BITBAND_SRAM_REF)*32 \    + (b*4))) // Convert SRAM address#define BITBAND_PERI_REF 0x40000000#define BITBAND_PERI_BASE 0x42000000#define BITBAND_PERI(a,b) ((BITBAND_PERI_BASE + (a-BITBAND_PERI_REF)*32 \    + (b*4))) // Convert PERI address
#define MAILBOX 0x20004000#define TIMER 0x40004000// Mailbox bit 0#define MBX_B0 *((volatile unsigned int *)(BITBAND_SRAM(MAILBOX,0)))// Mailbox bit 7#define MBX_B7 *((volatile unsigned int *)(BITBAND_SRAM(MAILBOX,7)))// Timer bit 0#define TIMER_B0 *((volatile unsigned char *)(BITBAND_PERI(TIMER,0)))// Timer bit 7#define TIMER_B7 *((volatile unsigned char *)(BITBAND_PERI(TIMER,7)))
int main(void){    unsigned int temp = 0;
    MBX_B0 = 1; // Word write    temp = MBX_B7; // Word read    TIMER_B0 = temp; // Byte write    return TIMER_B7; // Byte read}
"// Convert PERI address" what a useless comment, it only makes sense if you know what they are doing.
Is it implemented in hardware? I guess you have to set up the bit banding to work in certain memory areas and by default they are normally turned off.
If you set it up for an area then you reduce the memory available drastically.
Is it only for peripherals? It seems not, the mailbox is in RAM.
Can anyone explain it a bit more clearly? Or have another link?

 

Offline MuxrTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
Re: STM32F103 any good?
« Reply #26 on: April 23, 2015, 03:02:23 am »
That's pretty slick, this article explains it pretty well: http://spin.atomicobject.com/2013/02/08/bit-banding/
IMO that article just confuses me.
the link on the ARM website doesn't help much either.
Then the example? I should submit this code to www.thedailywtf.com Why the mailbox analogy?? for something supposedly atomic. Is it like an example of a single bit mailbox between processes?
Quote
#define BITBAND_SRAM_REF 0x20000000#define BITBAND_SRAM_BASE 0x22000000#define BITBAND_SRAM(a,b) ((BITBAND_SRAM_BASE + (a-BITBAND_SRAM_REF)*32 \    + (b*4))) // Convert SRAM address#define BITBAND_PERI_REF 0x40000000#define BITBAND_PERI_BASE 0x42000000#define BITBAND_PERI(a,b) ((BITBAND_PERI_BASE + (a-BITBAND_PERI_REF)*32 \    + (b*4))) // Convert PERI address
#define MAILBOX 0x20004000#define TIMER 0x40004000// Mailbox bit 0#define MBX_B0 *((volatile unsigned int *)(BITBAND_SRAM(MAILBOX,0)))// Mailbox bit 7#define MBX_B7 *((volatile unsigned int *)(BITBAND_SRAM(MAILBOX,7)))// Timer bit 0#define TIMER_B0 *((volatile unsigned char *)(BITBAND_PERI(TIMER,0)))// Timer bit 7#define TIMER_B7 *((volatile unsigned char *)(BITBAND_PERI(TIMER,7)))
int main(void){    unsigned int temp = 0;
    MBX_B0 = 1; // Word write    temp = MBX_B7; // Word read    TIMER_B0 = temp; // Byte write    return TIMER_B7; // Byte read}
"// Convert PERI address" what a useless comment, it only makes sense if you know what they are doing.
Is it implemented in hardware? I guess you have to set up the bit banding to work in certain memory areas and by default they are normally turned off.
If you set it up for an area then you reduce the memory available drastically.
Is it only for peripherals? It seems not, the mailbox is in RAM.
Can anyone explain it a bit more clearly? Or have another link?

I am going to try and explain my understanding of it. Let's first explain what issue it's trying to solve.

Suppose you have a register in memory that is of value 01001001. And suppose the first bit of that byte (currently 0) determines the GPIO pin mode and you want to flip it. You would have to load the entire byte 01001001 just to manipulate that one bit.

Why is this bad, you might ask? Well depending on how you manipulate it your manipulation might take multiple clock cycles to flip just that one bit, because you're dealing with a much bigger chunk of data. If your flipping of that bit takes multiple CPU cycles chances are something else might try to manipulate that byte and cause a race condition. It's basically equivalent of multiple people editing their local copies of the same spreadsheet, you get a mess, you don't know which one is the correct one.

For example, let's call your main program flow, program A, and some piece of code that runs on an interrupt, interrupt B.

Your program A is trying to flip the first bit, it reads the register. So far so good, but before it gets a chance to write the modified version of it, interrupt B piece of code flips a different bit in that byte. And since your program A is unaware it tries to save a stale version of the register byte into the memory, overwriting the change interrupt B was trying to accomplish. Very bad.

So to help developers avoid race condition Bit-banding was implemented. Bit-banding is a pseudo memory location with an interesting property. It's basically a mirror of all the registers but instead of storing 8 bits per byte it only stores one significant bit per byte.

So our little 01001001 becomes 8 distinct bytes in the bit-banding space: 00000000 (only holding the our first bit), 0100000 (only holding the 2nd bit)...etc The bytes in the bit-banding space are interconnected behind the scenes, and flipping a bit in one space, alters it in the other.

So now you can safely take a byte from the bit-banding location to only modify one bit without the fear of accidentally overwriting other bits with stale state. There is also a mention that manipulation bit-banding bytes is a single clock cycle operation making it fully atomic (impervious to race conditions, even on the same bit).

ps. bit-banding sounds terribly memory inefficient, you know "exploding" a byte into 8 bytes each containing 1 bit, but most likely it's all done logically so no memory is actually wasted, it's just wired like that behind the scenes.
« Last Edit: April 23, 2015, 03:14:35 am by Muxr »
 

Offline HackedFridgeMagnet

  • Super Contributor
  • ***
  • Posts: 2028
  • Country: au
Re: STM32F103 any good?
« Reply #27 on: April 23, 2015, 03:38:58 am »
Thanks for the attempt, but you explained the bit that I do know and not the bit that I don't know.
How is it wired behind the scenes?
What limitations, restrictions or compromises are there? 
I guess I could look it up in the M4 data sheet but until I get the time or use the something of the M4 series I wont worry.
I guess once you get the macros done it is easy to use, but the macros look fairly intimidating at the moment.
 

Offline MuxrTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
Re: STM32F103 any good?
« Reply #28 on: April 23, 2015, 03:53:47 am »
There is a bit more info on LinkedIN of all places: https://www.linkedin.com/groups/How-is-Bitbanding-actually-implemented-85447.S.5834088429486354434
Quote
Senior Embedded Technology Manager at ARM

The AHB interface on the processor automatically remap and generate the two bus accesses. it have a side band signal to indicate the read-modify-write sequence is locked (atomic). So even if there is a separate bus master in the system, the other bus master should not be able to inject another transfer in between. (That's assumed the bus interconnect in the system was designed properly :-) )

Quote
Applications Engineer at ARM

Try: http://infocenter.arm.com/help/topic/com.arm.doc.set.amba/index.html#amba3

You should find AHB-Lite under AMBA Specifications / AMBA 3
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1672
  • Country: pl
  • Troll Cave Electronics!
Re: STM32F103 any good?
« Reply #29 on: April 23, 2015, 11:30:17 am »
I will make an attempt to explain.

Suppose you have a register under address A with 32 bits in it. In order to change a bit you'd need to read the register, make a logic operation (for example |= 0x01 to set LSB high) and write it back. If the value in that register has changed in the meantime this change will be overwritten. Thi also takes more time as you have to read, modify and write.

Now the bitbanding works like that: for every bit-band-aliased register under address A, every bit X has an alias-address B which is a function of A and X. This address does not correspond to entire register, but rather to the bit X in register A. You can write a logic value L into address B, which will result in value of bit X in register A changing to L. So in short, every bit in a bit-band-aliased register has its own address somewhere in the address space. Formulas and macros for calculating bit-band alias addresses are availale on ARM website.

In the end if your macro and compile settings are done right, your instruction to switch bit 17 in register 0xDEADBEEF should compile to a single STR instruction (given, that number if bit is known at compile time). This way you could theoretically toggle a gpio pin with FPCU/2 frequency (leaving aside the limitations of gpio ports themselves and assuming that toggling is unrolled and not looped - looping overead in CM3 and CM4 is terribl)
I love the smell of FR4 in the morning!
 

Offline HackedFridgeMagnet

  • Super Contributor
  • ***
  • Posts: 2028
  • Country: au
Re: STM32F103 any good?
« Reply #30 on: April 23, 2015, 12:16:11 pm »
Thanks again for explaining. But I still haven't got to the nub of what doesn't seem right.

I can see how it works for registers, this doesn't seem hard at all, some RAM must be permanently dedicated to alias the registers, easy.

What I couldn't see was how it works to bitband some RAM.
Or is it only registers that are aliased? Initially I thought this but the sample code seem to be bit banding the RAM.
Which RAM is an alias for which RAM.
How do you set up a memory map for this?
Ok I will read the doco. I should address my ignorance. No pun intended.

 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1672
  • Country: pl
  • Troll Cave Electronics!
Re: STM32F103 any good?
« Reply #31 on: April 23, 2015, 12:45:20 pm »
I don't think that bulk RAM is bit-banded. And if it is I have never used this feature.

The alias addresses are not in RAM, they are simply in address space. When CPU detects write instruction to particular alias register is calculated backwards which bit in which register it should write.
I love the smell of FR4 in the morning!
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F103 any good?
« Reply #32 on: April 23, 2015, 01:10:44 pm »
Here you find official documentation from ARM regarding bit-banding. With drawing  :-+
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337h/Behcjiic.html
 

Offline HackedFridgeMagnet

  • Super Contributor
  • ***
  • Posts: 2028
  • Country: au
Re: STM32F103 any good?
« Reply #33 on: April 23, 2015, 02:03:54 pm »
Ok thanks now I got it.
 

Offline MuxrTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
Re: STM32F103 any good?
« Reply #34 on: April 23, 2015, 02:10:01 pm »
They map two different regions: the lowest 1Mb in SRAM gets mapped as well as the peripheral 1Mb registers get mapped into 2x32Mb bit-banding regions.

While this doesn't take any actual RAM it does eat away 64Mb of the available addressing space which is now 4Gb-64Mb.
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #35 on: April 30, 2015, 12:34:18 pm »
Hi,

I've bought one of those : http://www.ebay.com/itm/311156408508?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

I wanted to jump into ARM processor for some time and I thought this could be a good start. Being from China, no documentation comes with it and what made hesistant abouf ARM is the large choise of IDE/dev board. Is Coocox sufficient ?
 

Offline FreddyVictor

  • Regular Contributor
  • *
  • Posts: 164
  • Country: gb
Re: STM32F103 any good?
« Reply #36 on: April 30, 2015, 04:58:31 pm »
ST are very good at doing their own boards at a reasonable price: F103 version
not as cheap as your ebay one, but it does come with builtin STLink for easy code upload/debugging plus lots of documentation on their website

an alternative to the F103 is the F401 which I believe includes floating point unit
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: STM32F103 any good?
« Reply #37 on: April 30, 2015, 05:24:20 pm »
Hi,

I've bought one of those : http://www.ebay.com/itm/311156408508?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

I wanted to jump into ARM processor for some time and I thought this could be a good start. Being from China, no documentation comes with it and what made hesistant abouf ARM is the large choise of IDE/dev board. Is Coocox sufficient ?

CooCox should work, I had trouble when I tried it. I found emblocks worked better for me, together with an STLINK JTAG-SWD adapter which works well and is a lot cheaper then Segger.

If you are at all Arduino inclined you might look at www.st32duino.org, for an Arduino STM32 compatible package.
Bob
"All you said is just a bunch of opinions."
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #38 on: May 02, 2015, 04:39:58 pm »
thanks,

actually I've just realised that I needed an external programmer. I'm on the hunt for that now. I've documetation to read I think.

Those uC seem to be very interesting.

I don't know emblocks, I'm gonna do some homework.

Quote
If you are at all Arduino inclined you might look at www.st32duino.org, for an Arduino STM32 compatible package.

I'm not really keen on Arduino but I must admit that their plug-and-play system is sometime very enviable.
 

Online ajb

  • Super Contributor
  • ***
  • Posts: 2601
  • Country: us
Re: STM32F103 any good?
« Reply #39 on: May 02, 2015, 06:46:38 pm »
Hi,

I've bought one of those : http://www.ebay.com/itm/311156408508?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

I wanted to jump into ARM processor for some time and I thought this could be a good start. Being from China, no documentation comes with it and what made hesistant abouf ARM is the large choise of IDE/dev board. Is Coocox sufficient ?

CooCox should work, I had trouble when I tried it. I found emblocks worked better for me, together with an STLINK JTAG-SWD adapter which works well and is a lot cheaper then Segger.
I'll second this.  CoIDE was great and easy to use when it worked, but would frequently fail to build or debug a project for no obvious reason, would occasionally crash and destroy my project file in the process, and finally crashed so badly I had to reinstall it.  I didn't have the patience for all the configuration that Eclipse required, so I finally landed on Em::Blocks and am pretty happy. 

If you go with one of ST's dev boards they typically have a built in debugger, so no external tools is required.

If you're already comfortable with AVR, Atmel does make ARM MCUs as well, and they are fully supported by Atmel Studio just as their AVRs are.
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #40 on: May 03, 2015, 12:59:06 pm »
Yes I'm comfortable with AVR but I don't use their software, it crashed the machine at the first run  :-DD . I'm using AVRdude but I won't say no to debugger/simulator now...

Quote
If you go with one of ST's dev boards they typically have a built in debugger, so no external tools is required.

that was actually my first entention, buy a "discovery board" to get started. I think I still buy one, they're so cheap that it won't be a pain on the wallet.

I think there's also a ARM facility in code::block now that I'm writting this.



 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #41 on: September 05, 2015, 05:44:33 pm »
I bring life back to the thread.

I've this board that I'd like to use for a small thing


but I saw it mentioned along with Arduino or Mapple and wonder if I can program it without both. I know there's the SWD pin header which supposes that I can but maybe I'm missing something.  I've got a discovery board from ST that I can, apparantly, use as a programmer for external chip. I tried but nothing good.

Some people had experience with this board ?

 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F103 any good?
« Reply #42 on: September 05, 2015, 06:09:06 pm »
The shown board does not pass the absolute minimum to operate. Because it lacks capacitors. Or is the bottom loaded?

Also, if programming fails. The headers are for the bootloader, which should have no effect for swd, but still.
You do also know the Discovery board has headers you must change to use it as ST-Link only?
 
 

Offline Hideki

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: no
Re: STM32F103 any good?
« Reply #43 on: September 05, 2015, 06:40:55 pm »
I have used that board before with no trouble. There are more components on the bottom, including capacitors.

You will need a programmer. I used a cheap ST-LINK V2 clone like this  http://www.ebay.com/itm/ST-Link-V2-Mini-Metal-Shell-STM8-STM32-Emulator-Downloader-Programming-good-/251642538698?hash=item3a97106aca
I'm sure you can use the ST-LINK on the discovery board instead. It may have to be disconnected from the onboard chip first. I suggest reading the docs.

The header at the bottom is SWD. Connect up four wires from the programmer to the board and off you go (look up the pinout first).
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4414
  • Country: dk
Re: STM32F103 any good?
« Reply #44 on: September 05, 2015, 07:36:54 pm »
I have used that board before with no trouble. There are more components on the bottom, including capacitors.

You will need a programmer. I used a cheap ST-LINK V2 clone like this  http://www.ebay.com/itm/ST-Link-V2-Mini-Metal-Shell-STM8-STM32-Emulator-Downloader-Programming-good-/251642538698?hash=item3a97106aca
I'm sure you can use the ST-LINK on the discovery board instead. It may have to be disconnected from the onboard chip first. I suggest reading the docs.

The header at the bottom is SWD. Connect up four wires from the programmer to the board and off you go (look up the pinout first).

using a discovery board as st-link is simple, theres a six pin connector with the debug signals and then you move two jumpers

 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: STM32F103 any good?
« Reply #45 on: September 05, 2015, 08:23:58 pm »
I've this board that I'd like to use for a small thing but I saw it mentioned along with Arduino or Mapple and wonder if I can program it without both.
The chip has a ROM serial bootloader. The two jumpers control the boot mode. Read the documentation for details.

Offline SundayProgrammer

  • Contributor
  • Posts: 33
  • Country: fi
Re: STM32F103 any good?
« Reply #46 on: September 06, 2015, 02:58:55 pm »
Too bad that 48pin F103C8 does not have any DAC(s)...
(Dacs are only included in high density devices)

Axel.
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1672
  • Country: pl
  • Troll Cave Electronics!
Re: STM32F103 any good?
« Reply #47 on: September 06, 2015, 03:11:14 pm »
DACs on most STM32 chips suck. They have trouble reaching the bottom rail (minimum is like 30mV). If you enable output buffer,  then it gets completely ridiculous (like 0.3V). In general external rail to rail buffer is almost necessity...

Wys?ane z mojego HTC One M8s przy u?yciu Tapatalka

I love the smell of FR4 in the morning!
 

Offline Rolo

  • Regular Contributor
  • *
  • Posts: 206
  • Country: nl
Re: STM32F103 any good?
« Reply #48 on: September 06, 2015, 04:06:33 pm »
I bring life back to the thread.

I've this board that I'd like to use for a small thing


but I saw it mentioned along with Arduino or Mapple and wonder if I can program it without both. I know there's the SWD pin header which supposes that I can but maybe I'm missing something.  I've got a discovery board from ST that I can, apparantly, use as a programmer for external chip. I tried but nothing good.

Some people had experience with this board ?

You could also take a look at the Maple Mini clone boards that are available all over ebay. They have the STM32F103CBT6 MCU that has 128 Kb flash, the board in your picture you has 64K. You must make the translation from the Maple pin numbers but that's easy, all the original docu about the Maple Mini is still online. Extra bonus is that these boards can be used in mbed, just select the NucleoF103RB as platform.  Flash the bin file with the ST Link V2 programmer. One thing, the nucleo MCU has more pins so keep in mind not to use them in your code for the maple mini. In mbed the USB port on the Maple Mini does not work,  I use it as 5 volt supply in this setup. The USB pins are on the header so can be used as I/O.
« Last Edit: September 06, 2015, 04:38:29 pm by Rolo »
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #49 on: September 06, 2015, 08:38:40 pm »
I managed to flash the chip. I'll try to hook up some SPI dac and potentiometers in the next few days.

Quote
You could also take a look at the Maple Mini clone boards that are available all over ebay. They have the STM32F103CBT6 MCU that has 128 Kb flash, the board in your picture you has 64K

thanks I will. Right now it's more about the clock speed and processing than the memory size. By the way, is there any other ARM boards with other cortex? I can't really work with such small package (not equiped for) and these boards are better than nothing.
« Last Edit: September 06, 2015, 11:46:17 pm by old gregg »
 

Offline MuxrTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
Re: STM32F103 any good?
« Reply #50 on: September 07, 2015, 04:10:47 am »
I managed to flash the chip. I'll try to hook up some SPI dac and potentiometers in the next few days.

Quote
You could also take a look at the Maple Mini clone boards that are available all over ebay. They have the STM32F103CBT6 MCU that has 128 Kb flash, the board in your picture you has 64K

thanks I will. Right now it's more about the clock speed and processing than the memory size. By the way, is there any other ARM boards with other cortex? I can't really work with such small package (not equiped for) and these boards are better than nothing.
There are other Nucleo boards as well as Discovery ones. There is one for pretty much every model of STM32. I've been working with the F0 chips. The F030 for instance is a great tiny MCU for small projects. Less than a buck a piece.
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #51 on: September 07, 2015, 08:57:19 pm »
Quote
There are other Nucleo boards as well as Discovery ones. There is one for pretty much every model of STM32. I've been working with the F0 chips. The F030 for instance is a great tiny MCU for small projects. Less than a buck a piece.

yes but they're too bulky for my needs. I'll have a check on ebay.

However, yesterday I could flash the chip for the chinese board, today nothing ! grrr...
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #52 on: October 03, 2015, 06:55:28 pm »
Oddly enough I've just found out that the clock and data pin needed a pull down resistor in order to get connected. Since then, no issues at all. If this could useful to someone else.
 

Offline bson

  • Supporter
  • ****
  • Posts: 2269
  • Country: us
Re: STM32F103 any good?
« Reply #53 on: October 03, 2015, 09:29:36 pm »
It's not how ARM does it. It's how ST, NXP,  Atmel and such do it. ARM only provides the core,  all peripherals are of particular vendor's design.
Some peripherals such as the NVIC and the SysTick timer are part of the core.  The MPU is an optional core peripheral, so when implemented and present will be the ARM supplied one.

This may seem like counting angels, but it's important to know that all M3 processors have an NVIC (which includes NMI and software-generated interrupts and traps) and SysTick and that they will always look exactly the same.
 

Offline MT

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: aq
Re: STM32F103 any good?
« Reply #54 on: October 04, 2015, 01:00:30 am »
I've done some AVR development in the past. My background is software engineering so I don't mind learning a new language or environment.

But basically I've been shopping around for an MCU to migrate to after using 8Bit AVRs. I was mainly looking for cheap MCUs in case I decide I want to mass produce one of my projects, so the price is really important.

I was shocked with how cheap these (STM32) F103s are. For instance one of my projects is a clock and I have a need for an RTC module but this STM32 comes with a built in RTC. It's actually kind of mind boggling how much more advanced and how many more features F103 packs for the same price as an AVR Atmega328.

I mean you get: 75Mhz, 32Bit arch, 64Kb Flash, 20Kb SRAM, 2x12Bit ADC, bunch of interfaces, USB2.0, 7-channel DMA

I ordered a few of these $4 boards to play with: http://www.ebay.com/itm/311156408508?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

There is an open source Arduino toolchain: https://github.com/rogerclarkmelbourne/Arduino_STM32  It's pretty experimental though.

So I guess the question I have is, what's the catch? Anyone have experience with STM32 Cortex M3 F10x controllers, are they any good? And where should I begin in terms of software tools to program these guys? (preferably OS X / Linux toolchains).

Yes they are god, ST hardware is often very god! Download EMbitz/Blocks and create a F103 project and off you go in seconds.
Pricing? Now that's the hard part. You are then way better off with newer devices then F103, my experience from Farnell, Digikey, Mouser etc. 
 

Offline Rolo

  • Regular Contributor
  • *
  • Posts: 206
  • Country: nl
Re: STM32F103 any good?
« Reply #55 on: October 04, 2015, 09:24:37 am »
Oddly enough I've just found out that the clock and data pin needed a pull down resistor in order to get connected. Since then, no issues at all. If this could useful to someone else.

Thanks ! I had problems to get my Nucleo F401 board to work as ST-LINK programmer to program the Maple Mini clone. Now added two 4K7 pull-down resistors and it works.
« Last Edit: October 04, 2015, 09:27:10 am by Rolo »
 

Offline jnz

  • Frequent Contributor
  • **
  • Posts: 593
Re: STM32F103 any good?
« Reply #56 on: October 05, 2015, 06:40:34 pm »
Yes they are god, ST hardware is often very god! Download EMbitz/Blocks and create a F103 project and off you go in seconds.
Pricing? Now that's the hard part. You are then way better off with newer devices then F103, my experience from Farnell, Digikey, Mouser etc.

Well..... I don't know if they are THAT GOOD.

I do agree, starting a new project today, it'll be based on the F0, F2, or F4 depending on the project.
 

Offline richardman

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: us
Re: STM32F103 any good?
« Reply #57 on: October 05, 2015, 10:56:49 pm »
The F1xx series is very old, so comparing with an AVR, it does not have enough cost saving advantage like the F0xx, nor the power advantage like the F4xx. I would imagine that the F0xx (and other m0 cores) will dominate the low cost market and the F4xx (and other m4 cores) will dominate the power market.

Once the Cortex-M begins to "take over" the embedded mass market, for example, when a hobbyist/engineer that only makes one, or two, or ten units of a widget, and they still choose the Cortex-M instead of PIC or AVR, then that means that they have a good set of usable tools for the Cortex-M. At that time, the F1xx will be interesting again.
// richard http://imagecraft.com/
JumpStart C++ for Cortex (compiler/IDE/debugger): the fastest easiest way to get productive on Cortex-M.
Smart.IO: phone App for embedded systems with no app or wireless coding
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Re: STM32F103 any good?
« Reply #58 on: October 06, 2015, 06:09:53 pm »
I do like the F103 , but mostly for the price of assembled boards fro *bay or AliExp

I can get a board for $3.50.
If it's a "genuine" ST chip , then there's 128K Flash on the die, and you just need to convince OOCD  that the 64K ID has 128K, and you're good to go.

It's my new "Plugin board".

/Bingo
« Last Edit: October 07, 2015, 07:52:05 pm by bingo600 »
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #59 on: October 06, 2015, 06:26:56 pm »
Quote
Thanks ! I had problems to get my Nucleo F401 board to work as ST-LINK programmer to program the Maple Mini clone. Now added two 4K7 pull-down resistors and it works.

glad it helped !

Since I installed the two resitors, no issue occured again.

talking about the 103, I'm trying to write directly into register for the init of a pin. It doesn't work, What am I missing ?
Code: [Select]

RCC->APB2ENR |= RCC_APB2ENR_IOPCEN ;
GPIOC->CRH |= GPIO_CRH_MODE15; //OUT, 50Mhz
GPIOC->BSRR |= 1<<15;

I've got the nose in it so deep that I can't figure it out....

this works:
Code: [Select]
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_SetBits(GPIOC, GPIO_Pin_15); // LED2 On

Ideally, I'd like to have a look into the CRH registers to know what the bits are but I'm using coocox and I don't find a way to connect the stlink debugger.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: STM32F103 any good?
« Reply #60 on: October 07, 2015, 05:51:10 pm »
Code: [Select]
GPIOC->BSRR |= 1<<15;This should just be "GPIOC = 1<<15;", but I don't see that that should stop it from working.
It looks OK to me; are you still using "proven" code to initialize the system clocks?
https://www.eevblog.com/forum/microcontrollers/one-dollar-one-minute-arm-development/msg509546/#msg509546
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #61 on: October 11, 2015, 03:36:07 pm »
actually I assumed that the ports were loaded at 0 for all bits at boot time, which they aren't (noted in the datasheet, they're configured as floating input). I realised that with another line I found :
Quote
  GPIOC->CRH &= ~(GPIO_CRH_MODE12 | GPIO_CRH_CNF12);
I made a test, putting 0 in CRH and CRL at boot up, and then write the register as i want it to be, it worked.

Now I'm stuck with the SPI interface which output nothing. I haven't done things with the ADC neither, this seem to be a big one !

It's always a bit of pain when you move to other processor but I hope once all those settings learned this will go more easily.

Also, I don't want to use API libraries, just for the sake of understanding.



 

Offline daybyter

  • Frequent Contributor
  • **
  • Posts: 397
  • Country: de
Re: STM32F103 any good?
« Reply #62 on: October 12, 2015, 03:01:15 am »
If you want to explore the ADC, I would check the 10$ oscilloscope project of the stm32duino guys. Seems like they spend quite some time on optimization.

http://www.stm32duino.com/viewtopic.php?f=19&t=107
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #63 on: November 04, 2015, 02:15:17 pm »
I managed to get few things working. However, I've issue trying to get the SPI transmitting data via a timer interrupt. The chip select is switching fine but no clock and data (even with low prescaler for both)

Maybe someone encouters this problem and share the info.

I haven't reach DMA yet, so maybe it is related.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #64 on: November 05, 2015, 08:57:38 pm »
Seriously, man, why cannot you run through the examples provided by STM first instead of.. ok I wanted to write "wasting time" but let it be "personal quest" to save 1k of 128k available in that 2$ chip? They have put a lot of effort into these libraries and examples that come included. From my experience I can tell you that you won't be able to optimize much. Definitely you won't save on time (on writing+debugging+maintaining code) that could be spent on something "more challenging".
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F103 any good?
« Reply #65 on: November 05, 2015, 08:59:39 pm »
You can save 10us by not using the can library provided by ST.
You can save significant seconds by not using the spi library when writing an LCD without dma.
So well, yes. It takes a day. But gets you the few extra can messages per second. As well as a faster lcd refresh. Could be subject to debate. Some people have time, some don't.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #66 on: November 05, 2015, 09:32:37 pm »
(..)You can save significant seconds by not using the spi library when writing an LCD without dma.
So well, yes. It takes a day.(..)

Well, for SPI without DMA there is only one STM32F103 library function that does this job...

Code: [Select]
/**
  * @brief  Transmits a Data through the SPIx/I2Sx peripheral.
  * @param  SPIx: where x can be
  *   - 1, 2 or 3 in SPI mode
  *   - 2 or 3 in I2S mode
  * @param  Data : Data to be transmitted.
  * @retval None
  */
void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data)
{
  /* Check the parameters */
  assert_param(IS_SPI_ALL_PERIPH(SPIx));
 
  /* Write in the DR register the data to be sent */
  SPIx->DR = Data;
}

Seriously, what would you like to optimize here?
Shorter functions names?
Less doxygen or assert?


 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: STM32F103 any good?
« Reply #67 on: November 06, 2015, 01:31:49 am »
Quote
for SPI without DMA there is only one STM32F103 library function that does this job.
Perhaps, if you're going to use the OLD Standard Peripheral Library.  that's not recommended any more, you know.   You should now be using the STM32 CUBE HAL library, where the SPI transmit function reads:

Code: [Select]
HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)
{

  if(hspi->State == HAL_SPI_STATE_READY)
  {
    if((pData == NULL ) || (Size == 0))
    {
      return  HAL_ERROR;
    }

    /* Check the parameters */
    assert_param(IS_SPI_DIRECTION_2LINES_OR_1LINE(hspi->Init.Direction));

    /* Process Locked */
    __HAL_LOCK(hspi);

    /* Configure communication */
    hspi->State = HAL_SPI_STATE_BUSY_TX;
    hspi->ErrorCode   = HAL_SPI_ERROR_NONE;

    hspi->pTxBuffPtr  = pData;
    hspi->TxXferSize  = Size;
    hspi->TxXferCount = Size;

    /*Init field not used in handle to zero */
    hspi->TxISR = 0;
    hspi->RxISR = 0;
    hspi->pRxBuffPtr  = NULL;
    hspi->RxXferSize  = 0;
    hspi->RxXferCount = 0;

    /* Reset CRC Calculation */
    if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE)
    {
      SPI_RESET_CRC(hspi);
    }

    if(hspi->Init.Direction == SPI_DIRECTION_1LINE)
    {
      /* Configure communication direction : 1Line */
      SPI_1LINE_TX(hspi);
    }

    /* Check if the SPI is already enabled */
    if((hspi->Instance->CR1 &SPI_CR1_SPE) != SPI_CR1_SPE)
    {
      /* Enable SPI peripheral */
      __HAL_SPI_ENABLE(hspi);
    }

    /* Transmit data in 8 Bit mode */
    if(hspi->Init.DataSize == SPI_DATASIZE_8BIT)
    {
      if((hspi->Init.Mode == SPI_MODE_SLAVE)|| (hspi->TxXferCount == 0x01))
      {
        hspi->Instance->DR = (*hspi->pTxBuffPtr++);
        hspi->TxXferCount--;
      }

      while(hspi->TxXferCount > 0)
      {
        /* Wait until TXE flag is set to send data */
        if(SPI_WaitOnFlagUntilTimeout(hspi, SPI_FLAG_TXE, RESET, Timeout) != HAL_OK)
        {
          return HAL_TIMEOUT;
        }
        hspi->Instance->DR = (*hspi->pTxBuffPtr++);
        hspi->TxXferCount--;
      }
      /* Enable CRC Transmission */
      if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE)
      {
        SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT);
      }
    }
    /* Transmit data in 16 Bit mode */
    else
    {
      if((hspi->Init.Mode == SPI_MODE_SLAVE) || (hspi->TxXferCount == 0x01))
      {
        hspi->Instance->DR = *((uint16_t*)hspi->pTxBuffPtr);
        hspi->pTxBuffPtr+=2;
        hspi->TxXferCount--;
      }

      while(hspi->TxXferCount > 0)
      {
        /* Wait until TXE flag is set to send data */
        if(SPI_WaitOnFlagUntilTimeout(hspi, SPI_FLAG_TXE, RESET, Timeout) != HAL_OK)
        {
          return HAL_TIMEOUT;
        }
        hspi->Instance->DR = *((uint16_t*)hspi->pTxBuffPtr);
        hspi->pTxBuffPtr+=2;
        hspi->TxXferCount--;
      }
      /* Enable CRC Transmission */
      if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE)
      {
        SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT);
      }
    }

    /* Wait until TXE flag is set to send data */
    if(SPI_WaitOnFlagUntilTimeout(hspi, SPI_FLAG_TXE, RESET, Timeout) != HAL_OK)
    {
      SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG);
      return HAL_TIMEOUT;
    }

    /* Wait until Busy flag is reset before disabling SPI */
    if(SPI_WaitOnFlagUntilTimeout(hspi, SPI_FLAG_BSY, SET, Timeout) != HAL_OK)
    {
      SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG);
      return HAL_TIMEOUT;
    }
 
    /* Clear OVERUN flag in 2 Lines communication mode because received is not read */
    if(hspi->Init.Direction == SPI_DIRECTION_2LINES)
    {
      __HAL_SPI_CLEAR_OVRFLAG(hspi);
    }

    hspi->State = HAL_SPI_STATE_READY;

    /* Process Unlocked */
    __HAL_UNLOCK(hspi);

    return HAL_OK;
  }
  else
  {
    return HAL_BUSY;
  }
}
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F103 any good?
« Reply #68 on: November 06, 2015, 06:33:08 am »
The lack of multi byte write in the first driver is more what I'm pointing at. Which is more of an application example which should be phased out slowly when the software gets more mature.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #69 on: November 06, 2015, 08:14:44 am »
Perhaps, if you're going to use the OLD Standard Peripheral Library.  that's not recommended any more, you know.
Perhaps try Standard Peripheral Library when it does the job, before diving into HAL with OS.
Quote
You should now be using the STM32 CUBE HAL library, where the SPI transmit function reads:
That comes with whole HAL layer for OS. Anyway, what would you like to optimize in this polling:
Code: [Select]
      while(hspi->TxXferCount > 0)
      {
        /* Wait until TXE flag is set to send data */
        if(SPI_WaitOnFlagUntilTimeout(hspi, SPI_FLAG_TXE, RESET, Timeout) != HAL_OK)
        {
          return HAL_TIMEOUT;
        }
        hspi->Instance->DR = (*hspi->pTxBuffPtr++);
        hspi->TxXferCount--;
      }
? I cannot see a place for any improvements in terms of speed. Besides, STM32F103 SPI modules do 18Mbps max so with 16-bit data that gives at least 64 instructions for one loop. Same limit for -O0 and assembler and you won't make it faster anyway. If you want speed then use DMA (HAL provides separate API for that).
 
Quote
The lack of multi byte write in the first driver is more what I'm pointing at.
The STM peripheral library is just peripheral library. It does not make coffee, it does not play chess. If you want polling and multibyte transmission then you have to include your higher level layer above it (similar to example above). However, library comes with extensive set of examples (polling included) which are worth trying before considering the library "uselessly slow" and rewriting everything.
 

Offline gogoman

  • Regular Contributor
  • *
  • Posts: 116
Re: STM32F103 any good?
« Reply #70 on: November 15, 2015, 02:14:42 am »
I bring life back to the thread.

I've this board that I'd like to use for a small thing


Some people had experience with this board ?
I have the board,  it works.  can someone provides a schematic?
thanks
 

Offline HackedFridgeMagnet

  • Super Contributor
  • ***
  • Posts: 2028
  • Country: au
Re: STM32F103 any good?
« Reply #71 on: November 16, 2015, 10:44:07 pm »
I haven't got a schematic, but really you can see just about everything from the photo.

Low speed crystal + caps, High speed crystal (no caps?), USB, programming interface, 2 x jumper inputs, momentary button and a stack of pins brought out to the edge.
« Last Edit: November 16, 2015, 10:50:48 pm by HackedFridgeMagnet »
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: STM32F103 any good?
« Reply #72 on: November 17, 2015, 07:50:15 am »
I have never seen an official schematic for that board, despite much searching. The website https://vcc-gnd.world.taobao.com/ has a bunch of stuff, nothing I can find in English though. I might try asking a Chinese speaking colleague to have a look. Maybe one of the dodgy .rar files has a schematic.

There is a reverse engineered schematic here http://www.mikrocontroller.net/attachment/249868/STM32_Min_System_Dev_Board.pdf, which is probably close enough.

Bob
"All you said is just a bunch of opinions."
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #73 on: November 17, 2015, 01:12:12 pm »
Looks like it has a permanent 3,3V pullup on DP.
Another thing is that VDDA is short-circuited to VCC. Was it that hard to put an LC in between, Mr. Wong?
Then, there is 10u + 100n on the +5V input. That violates USB specs.
And 100n cap in parallel with pushbutton  :-+
 

Offline asgard20032

  • Regular Contributor
  • *
  • Posts: 184
Re: STM32F103 any good?
« Reply #74 on: November 17, 2015, 03:11:27 pm »
Quote from: Brutte link=topic=46614.msghttps://www.eevblog.com/forum/Smileys/default/cry.gif802196#msg802196 date=1447765932
Looks like it has a permanent 3,3V pullup on DP.
Another thing is that VDDA is short-circuited to VCC. Was it that hard to put an LC in between, Mr. Wong?
Then, there is 10u + 100n on the +5V input. That violates USB specs.
And 100n cap in parallel with pushbutton  :-+

Why LC? Why a 100n cap? Most of the time, when I open schematic with mcu, i see L, some C i didn't expect, and bunch of other piece. But when i look at the datasheet, for a typical/minimum/recommended design, they just put most of the time a resistor between the mcu reset and Vdd. (I am not talking about a particular mcu, but in general). Did I miss an application note, an interesting document, or a book like "How to electrically plug an mcu"? It would be interesting if someone here could guide me to the right resource to learn those subtlety or explain it here.
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: STM32F103 any good?
« Reply #75 on: November 17, 2015, 04:52:11 pm »
Why LC? Why a 100n cap? Most of the time, when I open schematic with mcu, i see L, some C i didn't expect, and bunch of other piece. But when i look at the datasheet, for a typical/minimum/recommended design, they just put most of the time a resistor between the mcu reset and Vdd. (I am not talking about a particular mcu, but in general). Did I miss an application note, an interesting document, or a book like "How to electrically plug an mcu"? It would be interesting if someone here could guide me to the right resource to learn those subtlety or explain it here.

Pretty much standard practice: LC as a low pass filter to reduce noise passed from the digital side of the supply (VDD) to the analog one (VDDA), a cap across the reset pushbutton to provide a minimum of debouncing.
Example of LC (a ferrite bead, actually) in the picture, cropped from a Discovery board schematic.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline asgard20032

  • Regular Contributor
  • *
  • Posts: 184
Re: STM32F103 any good?
« Reply #76 on: November 17, 2015, 05:07:29 pm »
Why LC and not RC? Which L to choose?
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: STM32F103 any good?
« Reply #77 on: November 17, 2015, 06:55:12 pm »
A reset switch doesn't need debouncing!

IME a lot of EEs have a rote method of design, often under the guide of "best practice", which leads to overcomplicated design and unnecessary components.
Bob
"All you said is just a bunch of opinions."
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #78 on: December 27, 2015, 09:51:56 pm »
I bring life back to the thread.

I've this board that I'd like to use for a small thing


Some people had experience with this board ?
I have the board,  it works.  can someone provides a schematic?
thanks

I uploaded the schematic.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #79 on: December 28, 2015, 04:37:08 pm »
Why DP pullup is 4k7?? And Boot0 is just flapping in the breeze?
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: STM32F103 any good?
« Reply #80 on: December 28, 2015, 06:57:04 pm »
Why DP pullup is 4k7?? And Boot0 is just flapping in the breeze?
The standard D+ pull-up value is 1.5k to +3.3V. However in this case the resistor pulls up to +5V so the value should be higher. This board does not have zener protection on D+ so 4.7k is sufficient, and since the resistor is not switched out after USB negotiation the less current it injects the better. Crude, but it works!

BOOT0 is connected through R3 to pin 44 of the STM32. The jumper sets it to GND or +3.3V.
« Last Edit: December 28, 2015, 06:59:16 pm by Bruce Abbott »
 

Offline ea_man

  • Contributor
  • Posts: 23
  • Country: it
Re: STM32F103 any good?
« Reply #81 on: December 28, 2015, 09:32:54 pm »
Why DP pullup is 4k7?? And Boot0 is just flapping in the breeze?
You are lucky: mine came with 10K and I had to solder a new one.
Weird thing is that now I have to use a USB HUB in order to upload, I'put a ~1.5k ohms resistor in that.

With 4.7k resistor does it work ok, enumeration and upload?
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #82 on: December 28, 2015, 09:54:16 pm »
The standard D+ pull-up value is 1.5k to +3.3V. However in this case the resistor pulls up to +5V so the value should be higher.
This design is a disaster. Looks like the USB spec has not been translated to Chinese yet.

Quote
BOOT0 is connected through R3 to pin 44 of the STM32. The jumper sets it to GND or +3.3V.
Ahh, now I can see that those are jumpers and select boot modes. PB2 is not routed externally.

Thanks for clarifying that.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM32F103 any good?
« Reply #83 on: December 31, 2015, 04:33:15 pm »
Quote
for historical reasons unknown to me became very popular in china some years ago.

It is one of the first CM3 chips that are so versatile at such a low price:

1) aside from the typical peripherals, it has DAC, lots of timers, DMA, CAN / USB, and built-in random number generator.
2) undocumented features.
3) good availability + form factor.

It is a little bit slow by today's standards but for many jobs it is fast enough.

Because of that, it is one of the very first cloned STM32F chips as well.
================================
https://dannyelectronics.wordpress.com/
 

Offline MagicSmoker

  • Super Contributor
  • ***
  • Posts: 1408
  • Country: us
Re: STM32F103 any good?
« Reply #84 on: December 31, 2015, 05:45:44 pm »
A reset switch doesn't need debouncing!

True, but the capacitor from !RESET to ground isn't for debouncing, it's for preventing spurious assertion from noise. Furthermore, a cap on reset costs very little, while the consequences of an unintended reset range from annoying to catastrophic, so there's no rational argument for leaving it off.

That said, I do agree with your general premise that most EEs seem to make things needlessly complex for the task at hand.
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: STM32F103 any good?
« Reply #85 on: December 31, 2015, 06:12:36 pm »
Yes, with hindsight (and some reading of data sheet  :-[) I would change that opinion - Reset is the only switch that needs a cap :).

I was recently reviewing a debug board we created at work, and 95% of it's functionality I've never used, and of the 5% there were other simpler says to do it. Plus the mounting by the mechanical guy was the worst design I have ever used. All it needed was a 10 pin JTAG IDC connector, would have been fine. I gave a colleague a copy of the "what the customer wanted" cartoon, he thought it was amusing but showed no signs of getting the message!

I concede this may say more about the ill-advised over-engineering we do at our company than the state of the industry in general.
Bob
"All you said is just a bunch of opinions."
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM32F103 any good?
« Reply #86 on: January 01, 2016, 12:45:43 pm »
Quote
the capacitor from !RESET to ground isn't for debouncing, it's for preventing spurious assertion from noise.

It is also a "power-good" indicator - to create a power-on delay.
================================
https://dannyelectronics.wordpress.com/
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6190
  • Country: us
Re: STM32F103 any good?
« Reply #87 on: January 01, 2016, 03:53:03 pm »
What kind of bootloader does this board use?  Is it a stock preprogrammed  bootloader that comes with the MCU?
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: STM32F103 any good?
« Reply #88 on: January 01, 2016, 06:33:32 pm »
If I recall correctly, there is only the built-in STM serial bootloader.
Bob
"All you said is just a bunch of opinions."
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F103 any good?
« Reply #89 on: January 01, 2016, 09:04:21 pm »
Most parts have bootloaders. Some only for UART, some also have CAN or USB. These are ROM bootloaders, you can always add your own through the ARM SWD interface.
Especially on these parts with their variety you should consult the manual before assuming that it will have bootloaders.
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6190
  • Country: us
Re: STM32F103 any good?
« Reply #90 on: January 01, 2016, 09:36:07 pm »
Most parts have bootloaders. Some only for UART, some also have CAN or USB. These are ROM bootloaders, you can always add your own through the ARM SWD interface.
Especially on these parts with their variety you should consult the manual before assuming that it will have bootloaders.

I am using an NXP Arm MCU that comes stock with a USB virtual disk bootloader. It's very handy because no software is required to upload, just file copy. Would like to try a similar one from ST if available.
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: STM32F103 any good?
« Reply #91 on: January 01, 2016, 09:48:13 pm »
I am using an NXP Arm MCU that comes stock with a USB virtual disk bootloader. It's very handy because no software is required to upload, just file copy. Would like to try a similar one from ST if available.

That is a nice feature, but I haven't seen it on any other MCUs so far - it's great for hobbyists, maybe not so useful in a commercial environment?
Bob
"All you said is just a bunch of opinions."
 

Offline neslekkim

  • Super Contributor
  • ***
  • Posts: 1305
  • Country: no
Re: STM32F103 any good?
« Reply #92 on: January 01, 2016, 10:26:10 pm »
The nucleo's from st have it, but that is maybe custom bootloader?
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6190
  • Country: us
Re: STM32F103 any good?
« Reply #93 on: January 01, 2016, 10:35:43 pm »
The nucleo's from st have it, but that is maybe custom bootloader?

One important feature in those MCU boards is the ability to clone them. Not to sell competing products but for application specific custom PCBs that are based on the same MCU design. If ST provides an after market bootloader, it's still very useful.
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: STM32F103 any good?
« Reply #94 on: January 01, 2016, 10:53:43 pm »
The nucleo's from st have it, but that is maybe custom bootloader?

I think all the Nucleo boards have a secondary MCU which provides the USB disk programming method for Mbed, as well as a JTAG interface via USB (ST-LINK).  STM have not published the source code for the firmware AFAIK.

Bob
"All you said is just a bunch of opinions."
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #95 on: January 01, 2016, 11:04:51 pm »
Quote
The nucleo's from st have it
The nucleo st-link V2-1 USB mass storage class feature is not a bootloader but a programmer (it runs on a device that is external to the target). A bootloader is the name of the code that resides inside of the target that is being programmed.
The st-link does come with a USB bootloader (that allows upgrading st-link itself) however it is not a mass storage class.

BTW, nucleo 64 do not provide target USB receptacle.
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1672
  • Country: pl
  • Troll Cave Electronics!
Re: STM32F103 any good?
« Reply #96 on: January 01, 2016, 11:14:55 pm »
The ST-Link mass storage component contains only some advertising and propaganda. As a matter if fact I recall reading somewhere that both versions of ST-Link use some side channel in disk management protocol to talk to PC. I recall having huge problems with V1 under Win7.

I think all newer STM32s have bootloaders over USB,  UART and some other interface (SPI iirc). Not sure about F103 as it is a pretty old part. I think it has UART bootloader.

Sent from my HTC One M8s using Tapatalk.

I love the smell of FR4 in the morning!
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: STM32F103 any good?
« Reply #97 on: January 02, 2016, 03:29:48 am »
Not sure about F103 as it is a pretty old part. I think it has UART bootloader.
Yes, it has the serial bootloader. To use it you just need a TTL serial adapter and ST's Flash Loader Demonstrator. This has a command line version which can be run from a batch file.

I am using the vcc-gnd dev board that old gregg posted the schematic for. I modified the batch file in the "1 dollar 1 minute" thread so that an asm source code file can be 'drag-and-dropped' onto it. It takes less than a second to assemble, download and run a program. For debugging I use Hyperterminal. 

To make a self-contained environment for each project I put the arm assembler and flash load programs in subdirectories. I just copied over the essential files so the whole lot only takes up 4.8MB on disk.

The attachment below includes my batch file and source code for an LED blink program that works on the vcc-gnd board. The batch file is set to use COM5. If you use a different port then change the number '5' in the stmflashloader parameter '--pn 5' to the number of your com port.
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #98 on: February 26, 2016, 02:52:57 pm »
that's great Bruce, thank you. I'll check it out.

I should add the 2 pull resistor on the programming buss required. It won't work without if programmed via the st-link of the discovery board.

At the moment I've terrible experience with the ADC, it simply doesn't work. It enters the IRQ_handler fine but it seems that the adc pin isn't mapped to the ADC or something.

 Although my understanding goes nicely on the F4 discovery board, the Vcc-Ground board is very frustating.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #99 on: March 01, 2016, 10:05:49 pm »
but it seems that the adc pin isn't mapped to the ADC or something.


I suggest that you should start with examples provided by ST instead of reinventing the wheel. Besides, all STM32F103 chips have internal temperature sensor so it could be a good starting point for verifying your theory.

And about the bootloader - the chip has USB device peripheral and ST provides DFUse.
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #100 on: March 01, 2016, 10:15:30 pm »
Quote
I suggest that you should start with examples provided by ST instead of reinventing the wheel. Besides, all STM32F103 chips have internal temperature sensor so it could be a good starting point for verifying your theory.

i've actually tried that as well and any of those examples worked.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #101 on: March 02, 2016, 08:58:41 am »
At the moment I've terrible experience with the ADC, it simply doesn't work (..)
i've actually tried that as well and any of those examples worked.
Sounds like a contradiction.
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #102 on: March 02, 2016, 11:30:04 am »
oups...I meant none of the example worked.

the ADC OEC flag is set and working but nothing moves in the ADC data register.
 

Offline Kilrah

  • Supporter
  • ****
  • Posts: 1852
  • Country: ch
Re: STM32F103 any good?
« Reply #103 on: March 02, 2016, 12:03:55 pm »
And about the bootloader - the chip has USB device peripheral and ST provides DFUse.
The F1s however don't have the DFU bootloader, only F2 and up.
 

Offline Rasz

  • Super Contributor
  • ***
  • Posts: 2616
  • Country: 00
    • My random blog.
Re: STM32F103 any good?
« Reply #104 on: March 02, 2016, 06:15:40 pm »
And about the bootloader - the chip has USB device peripheral and ST provides DFUse.
The F1s however don't have the DFU bootloader, only F2 and up.

http://libopencm3.org/wiki/USB_DFU
Who logs in to gdm? Not I, said the duck.
My fireplace is on fire, but in all the wrong places.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #105 on: March 02, 2016, 07:43:22 pm »
oups...I meant none of the example worked.
What have you done to that poor uC?  :-BROKE It is hard to blame a uC when other (last week at Nuremberg ST stated 1.6 billion of them) work as expected. Can you tell us something about your hardware design? Perhaps get some reputable f103 eval (nucleo) to run ST examples. BTW, the f103 is used in numerous USB scope designs as even smallest versions are capable of converting 2x1Msps at 12-bit resolution.

Quote
The F1s however don't have the DFU bootloader
in ROM but you can download anything to flash. Of course there is this chicken-egg problem at the beginning. Just my remark about using a USB-to-serial converter to upgrade a USB chip.
 

Offline dadler

  • Supporter
  • ****
  • Posts: 851
  • Country: us
Re: STM32F103 any good?
« Reply #106 on: March 02, 2016, 11:51:14 pm »
Is there any real reason to use these when the F410 is about the same price with better specs?

http://www.mouser.com/Search/ProductDetail.aspx?R=STM32F410RBT6virtualkey51120000virtualkey511-STM32F410RBT6
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM32F103 any good?
« Reply #107 on: March 02, 2016, 11:55:04 pm »
In many cases costs are not the only reason or even a major reason to pick a part.
================================
https://dannyelectronics.wordpress.com/
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #108 on: March 03, 2016, 11:25:59 am »
Quote
What have you done to that poor uC?

you guessed it....I've fried it it seems :palm: :palm: (or at least the input).

I used a second identical one and it worked as expected. Go figure what I've done to that uC.

Quote
Is there any real reason to use these when the F410 is about the same price with better specs?

it was cheap, small enough for what I want to do with it and easy to manage for one-off project.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 any good?
« Reply #109 on: March 03, 2016, 11:41:48 am »
Quote
What have you done to that poor uC?
you guessed it....I've fried it it seems :palm: :palm: (or at least the input).
I have made some remarks about STM32 IOs at the beginning of this topic. Not all IOs are 8V tolerant. However, that does not explain how come the internal temperature sensor misbehaved. Perhaps you have fried a multiplexer or ADCs..
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: STM32F103 any good?
« Reply #110 on: March 03, 2016, 06:15:01 pm »
I must have coocked the input driver or something. I'll check if the logic driver still work or not. I hate Breadboard for that kind of crap... |O (or it may as well be the uC which was already dead on the inside ... just to pretend I'm not responsible ::) )
 

Offline rexnanet

  • Newbie
  • Posts: 5
Re: STM32F103 any good?
« Reply #111 on: March 14, 2016, 04:34:48 pm »
I've known ST microcontrollers existed for a long time but haven't really used any.

But after getting very frustrated with a PIC32MX that didn't want to work (or failled after a few flash writes) (maybe because of cloned pickit lol) I quited! $%#$% them!

I'm also using a Stellaris Launchpad (now TIVA) to do some projects but it's a bit pricy to have a board for each project.

Then I saw that some people got F103 overclocked (up to 128M) and some other guys got it to work with arduino IDE (I'm not a big fan of arduino but it has lots of code already done...) I started to get interested.

Then I saw the price!!! 2-3€ for a board and 2-3€ for a programmer?!?! "Thats worth giving a try!" :)

It's fast :) I've managed to get SPI and I2C working with the master clock at 128Mhz and its faster than the Stellaris!
It has fewer pins but for small projects it's enough. For bigger ones I'm getting a F429 and also a F746.

There are not many ready made examples to get started but going step by step it's fairly easy to get stuff working.

 

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: us
Re: STM32F103 any good?
« Reply #112 on: March 14, 2016, 06:08:42 pm »
It's fast :) I've managed to get SPI and I2C working with the master clock at 128Mhz and its faster than the Stellaris!

Do you really need the extra speed enough to risk running the part at a clock rate well above what it's specified for?
Complexity is the number-one enemy of high-quality code.
 

Offline rexnanet

  • Newbie
  • Posts: 5
Re: STM32F103 any good?
« Reply #113 on: March 21, 2016, 02:56:03 pm »
Do you really need the extra speed enough to risk running the part at a clock rate well above what it's specified for?

In this case yes :)

First, I'm just testing the micro to see what it's capable of.
Second, Im not making anything that has a risk involved.
Third, I'm using it to interface a SPI TFT, so more speed=more fps=nicer interface :)

Yes, it's a risk and it might fail but for this purpose it's not a big deal.

 

Offline TonyD

  • Contributor
  • Posts: 12
  • Country: gb
Re: STM32F103 any good?
« Reply #114 on: March 26, 2016, 01:14:47 am »
I'm a bit late to the discussion but I'd just to say we've been using the STM32F103RB at work for the last 5-years or so, in about 30 products will in total volume of 40K+ pieces a year. We found it a fine uC and good support from ST (sorry for the flag waving). It must have something going for it if its being copied by a far-east company ;-)
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM32F103 any good?
« Reply #115 on: March 26, 2016, 01:17:41 am »
Quote
if its being copied by a far-east company

GD......, :)

I suspect many of the 103s on ebay are actually GD.
================================
https://dannyelectronics.wordpress.com/
 

Offline martinayotte

  • Regular Contributor
  • *
  • Posts: 64
Re: STM32F103 any good?
« Reply #116 on: March 29, 2016, 09:24:48 pm »
I suspect many of the 103s on ebay are actually GD.
GD are not fake/clone of STM, only that they are almost compatible.
So, pictures of board on eBay that showing STM should be STM. Boards with GD will cleary show the GD logo.
 

Offline michaeliv

  • Frequent Contributor
  • **
  • Posts: 260
Re: STM32F103 any good?
« Reply #117 on: March 30, 2016, 12:58:32 am »
GD are not fake/clone of STM, only that they are almost compatible.
So, pictures of board on eBay that showing STM should be STM. Boards with GD will cleary show the GD logo.
Any reason to think that they are genuine other than the rock-solid trustworthiness of Chinese sellers ?
I think he was saying that the STM32 chips are re-branded GD32 chips.
Kind of like how certain op-amps & voltage references are re-marked and sold for higher prices (happened to me).
Are the GD32 / STM32 chips not 100% compatible ? Does anyone know any differences between them ?
 

Offline stmdude

  • Frequent Contributor
  • **
  • Posts: 479
  • Country: se
Re: STM32F103 any good?
« Reply #118 on: March 30, 2016, 07:36:54 pm »
Are the GD32 / STM32 chips not 100% compatible ? Does anyone know any differences between them ?

They seem to be at least very compatible. There's no way of testing every single gate in them.

Olimex got in contact with GigaDevices, and got samples to test:
https://olimex.wordpress.com/2015/12/21/gd32f103rbt6-the-stm32-pin-to-pin-compatible-chinese-mcus-sample-test/
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM32F103 any good?
« Reply #119 on: March 30, 2016, 08:10:19 pm »
Quote
Are the GD32 / STM32 chips not 100% compatible ?

The demo I have seen suggests that they are binary compatible. You can also use ST libraries to develop for GD32, :).

From a hardware perspective, the GD has a newer core, runs faster, and has a "working" I2C module - the I2C module on F1 is not exactly flawed. Just that they are not compatible with ST library but that's more (but not a complete) an indication of ST software developers than its hardware developers.

The only known issue (that I'm aware of) is that the GD chips have a noisier ADC.
================================
https://dannyelectronics.wordpress.com/
 

Offline michaeliv

  • Frequent Contributor
  • **
  • Posts: 260
Re: STM32F103 any good?
« Reply #120 on: March 30, 2016, 09:23:29 pm »
the GD has a newer core, runs faster
Do they actually run faster or is it more a case of "well we clocked it higher at 25C and it worked for us, mark it faster in the datasheet".
As in, if you clock the STM32 & GD32 at 120MHZ, the STM32 will give errors when the GD32 will not ?
Also is there a software way to tell which chip is which, like FTDI detected managed to detect non-FTDI chips? I'm asssuming that measuring ADC noise would not be that reliable.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM32F103 any good?
« Reply #121 on: March 30, 2016, 10:25:58 pm »
GD32(F103) runs at 108Mhz, on a r2p1 core, with WS0 flash. Whether that translates into actual faster speed all depends on what you are "running" on it: Reading from flash for example is much faster. Writing to flash is considerably slower however.

There are also some well-known differences as well.

One of the frustrations with GD32 has been the inability to tell it apart from STM32 using software alone.
================================
https://dannyelectronics.wordpress.com/
 

Offline martinayotte

  • Regular Contributor
  • *
  • Posts: 64
Re: STM32F103 any good?
« Reply #122 on: March 31, 2016, 04:31:21 pm »
Yes, GD and STM are almost compatible. One difference that I know is that PLL has more bits to provide more frequency ratios, for example, to get proper USB clock even if MCU isn't at the same frequency as STM.

BTW, for those who wish to see that the GD die isn't a clone of STM at all, here is a nice link, which also explain why the Flash is much faster on GD than STM :

http://zeptobars.com/en/read/GD32F103CBT6-mcm-serial-flash-Giga-Devices
 

Offline savril

  • Regular Contributor
  • *
  • Posts: 66
  • Country: fr
Re: STM32F103 any good?
« Reply #123 on: April 01, 2016, 09:00:57 pm »
Quote
Are the GD32 / STM32 chips not 100% compatible ?

The demo I have seen suggests that they are binary compatible. You can also use ST libraries to develop for GD32, :).

If I'm right, the SDK for GD32 was a carbon copy of STM32 SDK only with the ST copyrights removed (GD have changed some source files since the launch however).
There is a legal complaint from ST and that source copy seem an advantage on ST side.

Even if they can't forbid the chip as it is not a silicon copy, ST may be able to make all software developed with their SDK illegal to run on non ST chips. And so all products made with ST SDK (or GD copied one) could be marked as counterfeits...

As a hobbyist, I don't care. But if I was making a product, I would think twice before including a GD chip in my design.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM32F103 any good?
« Reply #124 on: April 01, 2016, 09:50:24 pm »
Quote
the SDK for GD32 was a carbon copy of STM32 SDK

Some changes to the stm libraries are needed to support the higher clock rates. Other than that, you can literally use the stm32 library to develop code for gd32.
================================
https://dannyelectronics.wordpress.com/
 

Offline Rasz

  • Super Contributor
  • ***
  • Posts: 2616
  • Country: 00
    • My random blog.
Re: STM32F103 any good?
« Reply #125 on: April 02, 2016, 05:05:38 am »
Yes, GD and STM are almost compatible. One difference that I know is that PLL has more bits to provide more frequency ratios, for example, to get proper USB clock even if MCU isn't at the same frequency as STM.

BTW, for those who wish to see that the GD die isn't a clone of STM at all, here is a nice link, which also explain why the Flash is much faster on GD than STM :

http://zeptobars.com/en/read/GD32F103CBT6-mcm-serial-flash-Giga-Devices

now THAT is fascinating, imagine if there was a way to use that SRAM as real ram and not serial flash buffer :o
Who logs in to gdm? Not I, said the duck.
My fireplace is on fire, but in all the wrong places.
 

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: us
Re: STM32F103 any good?
« Reply #126 on: April 04, 2016, 04:56:20 pm »
Yes, GD and STM are almost compatible. One difference that I know is that PLL has more bits to provide more frequency ratios, for example, to get proper USB clock even if MCU isn't at the same frequency as STM.

BTW, for those who wish to see that the GD die isn't a clone of STM at all, here is a nice link, which also explain why the Flash is much faster on GD than STM :

http://zeptobars.com/en/read/GD32F103CBT6-mcm-serial-flash-Giga-Devices

now THAT is fascinating, imagine if there was a way to use that SRAM as real ram and not serial flash buffer :o

Yes, fascinating. If his post was a day later, I probably wouldn't have believed it and assumed it was an April Fools Day joke.
Complexity is the number-one enemy of high-quality code.
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: STM32F103 any good?
« Reply #127 on: April 08, 2016, 08:08:58 pm »
Quote
the SDK for GD32 was a carbon copy of STM32 SDK

Some changes to the stm libraries are needed to support the higher clock rates. Other than that, you can literally use the stm32 library to develop code for gd32.

It won't be long before someone develop a LGPL-licensed replacement (like avr-libc and avr-gcc.) Then there is no control over ST on the SDK. GD will have all the intention to do that.
 

Offline martinayotte

  • Regular Contributor
  • *
  • Posts: 64
Re: STM32F103 any good?
« Reply #128 on: April 09, 2016, 12:37:48 pm »
Simply go to stm32duino.com, there is already GD32 support.
 

Offline textshell

  • Newbie
  • Posts: 3
  • Country: de
Re: STM32F103 any good?
« Reply #129 on: April 18, 2016, 10:09:35 pm »
The small chinese boards that are all over aliexpress and ebays as "minimal system board" are possibly made by Haoyu electronics. At least that’s what the german store watterott gives as manufacturer. They even have schematics:
http://www.haoyuelectronics.com/Attachment/STM32F103C8T6-DEV-BOARD/STM32F103C8T6-DEV-BOARD-SCH.pdf

Also if anyone wants to understand what is really needed and why for the gcc toolchain (linkerscripts, etc) i wrote a blog series about bringing up such a board[1] just using the register headers and a linaro bare-metal gcc. (questions and ideas improvements welcome too of course). Without a single line of assembler. But it might contain c++

[1] http://tty.uchuujin.de/2016/02/stm32-from-scratch-bare-minimals/
 
The following users thanked this post: Rasz, neslekkim

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM32F103 any good?
« Reply #130 on: April 18, 2016, 10:21:52 pm »
I have used those boards under keil (from 3.24 to 4.x), iar (through 6.4), coide (1.x plus an old gcc), and arduino, programmed through stlink and jlink, with cmsis and stdperipheral libraries.

They are some of the easiest think to do: either copy over an existing project or click some butons under coide. 30 seconds tops will get you up and running.

They are amazing values, especially coupled with stlink clones.
================================
https://dannyelectronics.wordpress.com/
 

Offline textshell

  • Newbie
  • Posts: 3
  • Country: de
Re: STM32F103 any good?
« Reply #131 on: April 18, 2016, 10:52:53 pm »
does anyone have a recommendation what debugger adapter works well with a pure open source toolchain (i.e. gdb, maybe openocd or something else?) and JTAG and SWD?
 

Offline HackedFridgeMagnet

  • Super Contributor
  • ***
  • Posts: 2028
  • Country: au
Re: STM32F103 any good?
« Reply #132 on: April 18, 2016, 11:35:09 pm »
stlink v2 works fine, but its the only one I've tried but I have only tried it with SWD though I think it does JTAG.
« Last Edit: April 18, 2016, 11:37:07 pm by HackedFridgeMagnet »
 

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: us
Re: STM32F103 any good?
« Reply #133 on: April 19, 2016, 12:11:45 am »
does anyone have a recommendation what debugger adapter works well with a pure open source toolchain (i.e. gdb, maybe openocd or something else?) and JTAG and SWD?

The most robust debugger I've worked with is the Segger J-Link. Works with GDB and does both JTAG and SWD. The EDU version is only $60/€48.
Complexity is the number-one enemy of high-quality code.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F103 any good?
« Reply #134 on: April 19, 2016, 04:30:17 am »
Segger has an ethernet version! Slap on a small wifi router and you have wireless debugging.
But I use a uLink, got one when they dismantled the department I was an intern.
 

Offline neslekkim

  • Super Contributor
  • ***
  • Posts: 1305
  • Country: no
Re: STM32F103 any good?
« Reply #135 on: April 20, 2016, 08:28:40 am »
 

Offline neslekkim

  • Super Contributor
  • ***
  • Posts: 1305
  • Country: no
Re: STM32F103 any good?
« Reply #136 on: April 20, 2016, 08:30:01 am »
The small chinese boards that are all over aliexpress and ebays as "minimal system board" are possibly made by Haoyu electronics. At least that’s what the german store watterott gives as manufacturer. They even have schematics:
http://www.haoyuelectronics.com/Attachment/STM32F103C8T6-DEV-BOARD/STM32F103C8T6-DEV-BOARD-SCH.pdf

Also if anyone wants to understand what is really needed and why for the gcc toolchain (linkerscripts, etc) i wrote a blog series about bringing up such a board[1] just using the register headers and a linaro bare-metal gcc. (questions and ideas improvements welcome too of course). Without a single line of assembler. But it might contain c++

[1] http://tty.uchuujin.de/2016/02/stm32-from-scratch-bare-minimals/

This looks cool, i bought some of those boards, but newer got around to do anything, this blogseries would help jumpstarting it.
But, what about an 0 post, prerequisites for software setup?
 

Offline dgtl

  • Regular Contributor
  • *
  • Posts: 183
  • Country: ee
Re: STM32F103 any good?
« Reply #137 on: April 20, 2016, 06:24:14 pm »
this thingy ? https://github.com/texane/stlink
This works well, been using it on a lot of projects. My setup is:
* gcc-arm-embedded from https://launchpad.net/gcc-arm-embedded
* eclipse + cdt
* gnu arm plugin for eclipse
* texane stlink gdb server
The linker script and cpu init code can be generated using cubemx and then customized for own needs (I'm not using any st-provided hal libs, only the cpu header file).
 

Offline textshell

  • Newbie
  • Posts: 3
  • Country: de
Re: STM32F103 any good?
« Reply #138 on: April 22, 2016, 05:41:15 pm »
Also if anyone wants to understand what is really needed and why for the gcc toolchain (linkerscripts, etc) i wrote a blog series about bringing up such a board[1] just using the register headers and a linaro bare-metal gcc. (questions and ideas improvements welcome too of course). Without a single line of assembler. But it might contain c++

[1] http://tty.uchuujin.de/2016/02/stm32-from-scratch-bare-minimals/

This looks cool, i bought some of those boards, but newer got around to do anything, this blogseries would help jumpstarting it.
But, what about an 0 post, prerequisites for software setup?

Yes, maybe i should add something more about prerequisites. For now the README.md on github (linked from every post) has the software versions i use. But it’s somewhat minimal because most of everything is just part of my OS (Debian linux). I guess on windows setup would be a bit more painful. But i think even for windows the gnu toolchain is not too complicated to get.

And as i don’t use any IDE like eclipse or anything like that, you only need stm32flash and the arm bare-metal version of the gcc toolchain.

If you have any questions, i’m happy to help.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf