cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F10x_StdPeriph_Lib, is it worth the trouble?

Fristedt.Jan
Associate II
Posted on March 01, 2010 at 08:13

STM32F10x_StdPeriph_Lib, is it worth the trouble?

#setting-a-bad-example
11 REPLIES 11
Andrew Neil
Evangelist III
Posted on May 17, 2011 at 13:41

Have you actaully tried reading the User Manual?

If you find the Library documentation ''complicated to use and very verbose'', I suspect that you will find the same with the User Manual...

Fristedt.Jan
Associate II
Posted on May 17, 2011 at 13:41

Yes, RM0008 is 995 pages of pure goodness :o)

I guess my background in hardware changed my brain for ever.

/Janne

swhite2
Associate III
Posted on May 17, 2011 at 13:41

Your call. As an electrical engineer with over 25 years of experience I've done my own fair-share of reading uP manuals and creating my own drivers for peripherals.That said times have changed. Many vendors now do this work for you and development times are shorter.

If you prefer, like a collegue of mine, to read 1000 page manuals and know every bit in every register then knock yourself out. On the other hand if you prefer to get your project going quickly use the library.

One caveat though. The library documentation only describes the API's. It does not describe the peripheral functionality. You still have to read the manual for that and figure out, for yourself (i.e. read the source code) , what the library functions do.

Personally I recently completed a project, having never used a STM32, and use the library because I was able to get the hardware up and going quite quickly.

Fristedt.Jan
Associate II
Posted on May 17, 2011 at 13:41

You mean quickly, like in spending most of the day debugging the USART interrupt example that came with the library and finding:

1. USART clock not enabled.

2. USART not enabled.

3. PORTA and alternate function I/O clocks not enabled.

4. Rx and Tx pins not configured.

Is the code in the library of similar quality as the example code?

Should I be impressed by the work done by the good people in the MCD Application Team?

John F.
Senior
Posted on May 17, 2011 at 13:41

Did you define for example, ''USE_STM3210B_EVAL'' or whatever is applicable for your system? These are needed to control the GPIO initialisation. Although the library MAY have faults (read of RTC registers without checking for change in high word for example), it makes it much simpler to get on. You can always review the library source and copy and modify it if you need to or rewrite a function that needs speed in assembler if you have that skill.

tkreyche
Associate
Posted on May 17, 2011 at 13:41

Janne,

I am entirely sympathetic and in agreement with you. I've been trying to get a simple interrupt based I2C comnumication working with temperature sensor. The STM32F10x_StdPeriph_Lib and related examples are cryptic at best. I was easily able to get the communications working on an LPCXpresso is a couple hours, and after spending a couple days on STM32 am not even close.

...Tom

supercoolman
Associate II
Posted on May 17, 2011 at 13:41

This is a complex chip, so everything cannot be done in simple ways. with that said, it doesn't matter whether people use lib or not, they must read user manual and datasheet. That's my experience from the past few weeks of trial and error on cortex chip. cortex is a very powerful chip if you want to do generic things, but not so powerful if you want to do a small set of very specific tasks.

swhite2
Associate III
Posted on May 17, 2011 at 13:41

I come from a era when manufacturers handed you a datasheet, a chip, and wished you the best of luck.

These days many ''engineers'' seem to expect the vendor (or someone) to write their application for them without all that hard work of figuring out how the chip actually works. How times have changed.

Admittedly ST's (and they're not alone in this) example projects are rather simplistic and aren't that useful, IMO, in a real design. It'd be nice if there were lots of comments to explain what is going on. Then again how many people do that? (I average a 50/50 ratio of code/comments).

I've spent many hours going through the library help file, the library source code, and the example source code to understand things. That effort has paid off and I now understand the STM32 very well.I've written my own drivers (i.e. didn't blindly copy example code) and liberally commented them.

I've run across a few undocumented gotcha's that were solved by calling an ST FAE. I'd expect this of any device of similar complexity. That said they were rather minor in the overall scheme of things.

Andrew Neil
Evangelist III
Posted on May 17, 2011 at 13:41

''ST's (and they're not alone in this) example projects are rather simplistic and aren't that useful, IMO''

 

 

I'm afraid I'd have to agree with you there!

ST (like too many others) seem to have totally missed the point and target audience of ''sample'' or ''example'' code:

  • The Purpose is to inform and explain;
  • The Target Audience is people who are not familiar with the software and/or the hardware
Clearly, these are not served by terse and/or sparse comments, nor by using any kind of ''clever tricks'' in the source code.

Sample code needs to be exemplary in both the quantity and the quality of its comments,  and those comments need to clearly describe each step of the process, and each variable used, and the project settings, etc - as well as giving an overview!

''It'd be nice if there were lots of comments to explain what is going on.''

 

 

 

Not just ''nice'' - absolutely essential if it is to serve its purpose as example code!

 

 

''Then again how many people do that?''

 

 

 

But ''most people'' are not writing example code!

The specific purpose of example code requires it!