cancel
Showing results for 
Search instead for 
Did you mean: 

New to STM32 , need a good tutorial.

bd678834
Associate II
Posted on December 22, 2009 at 08:32

New to STM32 , need a good tutorial.

#fail
11 REPLIES 11
bd678834
Associate II
Posted on May 17, 2011 at 13:33

Hello all !

I have much experience with PICs, but the ARM field is all new to me.

I would like to ask you guys for some good tutorials.

I looked some examples and it was difficult to understand by myself at some point. So i am asking for help from the experts 8-)

What STM32 mcu to use for the beginning ?

What compiler to use , ride keil IAR ?

Is there any libraries, tools , flashers , debuggers ?

Any information will be appreciated , thank you :D

tomas23
Associate II
Posted on May 17, 2011 at 13:33

Insiders Guide to STM32 by Hitex could help, freely downloadable from web

armmcu
Associate II
Posted on May 17, 2011 at 13:33

Hi bd678834,

Indeed the Insiders Guide to STM32 is a good reference for beginers.

Find also below a link of an online trainning for STM32 microcontrollers by ST.

Sometimes listen is better than read.

http://www.st.com/stonline/domains/support/epresentations/stm32/stm32.htm?wt.mc_id=enews_sep09_stm32epresentation

Cheers.

Armmcu.

embeddedm3
Associate
Posted on May 17, 2011 at 13:33

I have found Joseph Yiu's ''The Definitive Guide to ARM Cortex M3'' to be a very complete and readable introductory tome. One ARM FAE in my acquaintance described it as ''the datasheet written in English.'' You can read most of it at:

http://books.google.com/books?id=T9heqSaErCcC&dq=joseph+yiu+definitive+guide+to+cortex+m3&printsec=frontcover&source=bl&ots=eNuqEbKh0z&sig=ruXv3dk8ZNpt2RVa3zOFQJnuhb8&hl=en&ei=8_koS46BCoSwlAfQqOmqDQ&sa=X&oi=book_result&ct=result&resnum=3&ved=0CA4Q6AEwAg#v=onepage&q=&f=false

I have both the Keil and IAR starter kits for STM32. There is a rich source of code examples and both include the peripheral firmware library which is excellent. Either one of these kits is a very good investment. There is nothing like blinking a real LED to further your understanding of an architecture.

picguy
Associate II
Posted on May 17, 2011 at 13:33

PIC to ARM. That’s quite a transition. On $0.50 PICs you can multiply two 32-bit numbers. It’s a lot of code and you have to think hard about how to propagate carries when writing that multiply. (After all, I am PICguy. I’ve been there, done that.) On a $5.00 Cortex-M3 a single instruction can multiply two 32-bit numbers giving a 64-bit product. Actually there are 4 such instructions - signed or unsigned operands each operand type with the option of adding the product to the destination registers or simply storing it.

You don’t have to stick with assembly language. C/C++ code runs very well on Cortex-M3. But if you use assembly you will have to get used to its RISC architecture. A simple PIC “INCF ctr�? is 3 to 5 instructions. If you have the address of ctr in a register you have to load addr into a register, add 1 to the register and store the register back. This part is 3 16-bit instructions. To put the address of ctr in a register there are two main choices: mov32 which generates two 32-bit instructions or loading a literal which is typically a 16-bit PC-relative load of a 32-bit constant. The 2 instruction mov32 is faster.

If you have written PIC ISR’s you will love how ARM made ISR code fast and easy.

In addition to any “Cortex-M3 Made Easy�? books you will need ST’s RM0008 and pinout info for the parts you intend to use and ARM’s cortex_m3_r2p0. Read everything 100% at least once. It will make you dizzy but IMHO it’s the best way to learn the 5-10% of the information YOU need to learn.

Download the free Keil or IAR development tools. These tools are size and feature limited. For example, the free IAR C/C++ compiler will not output its generated assembly code in a form suitable for inserting into an assembly module. However you can see its generated code in the debugger. A 32K size limit poses no limitations on learning about the processor and the tool set you choose.

Write code and run it on the simulator before you try it on evaluation boards.

jj
Associate II
Posted on May 17, 2011 at 13:33

Believe the guys have given good & caring advice. (I really respect the generous contributions of this group)

Like you - my firm had used mostly 8 bit - started with ARM in 2006.

I would advise:

a) nothing will come easy

b) nothing will come quickly

c) if you are like many - you will ''rebel'' at the hundreds of lines of code - ''just'' to blink a single Led. Some have noted that the ARM process is ''unduly complicated.'' I want you to be fore-warned - unless very simple any ''rush'' project is doomed.

The complication results from ARM/vendor's attempt to maximize flexibility and capability. Often they've succeeded - but at the cost of clarity and straight-forwardness.

As others have advised - avoid ''maximum randomness'' at all costs. Start with a new, ''known good'' eval board and a ''pro'' IDE. (either Keil or IAR - I suggest) Later - as/if you like/can profit from this device - you can investigate other methods of development. Again - allow plenty of time - one subject at a time - be sure to document every step.

From bitter experience - avoid ''appropriation/use'' of the JTAG pins till you're pretty much expert. It is very easy to ''go into the weeds'' - and very demoralizing to spend the time/effort to recover.

When you return to the forum - spend time to clearly subject your question. Provide sufficient information so that you can be helped and it is preferred that you ''close the loop'' by telling the forum what worked/failed.

Best of luck...

JJ

ahnniu
Associate II
Posted on May 17, 2011 at 13:33

Hi bd678834,

There is a set of free development tools for the Cortex M3 on

http://coocox.org/

. You can use the Builder to build applications based on CoOs ,use CoFlash to download, and CoDebugger to debug.

Free and Open debug probe --Colink,

http://www.coocox.org/Colink.htm

Free and Open RTOS--CoOS,

http://www.coocox.org/CoOS.htm

Free and Pioneering IDE -- CoBuilder,

http://www.coocox.org/CooCox_Builder.htm

Free Flash Programmer -- CoFlash,

http://www.coocox.org/CoFlash_Programmer.htm

Free Debugging tool -- CoDebugger,

http://www.coocox.org/CooCox_CoDebugger.htm

Enjoy it!

jhalfmoon
Associate
Posted on May 17, 2011 at 13:33

That's some good advice up there. Indeed, spend time reading the introductory material en then try to get down and dirty as soon as possible; it's the best way to learn. But don't rush it. And participate in forums like this one.

I also spent a fair time getting to know this beast. I collected and published some useful links over here:

http://milksnot.com/content/arm-cortex-m3-getting-started

That should keep you of the street for a while I think.

stm32newbie
Associate
Posted on January 13, 2012 at 03:23

Useful link

http://www.cplusplus.com/reference/clibrary/cmath/

I am newbie in STM32 (and micro controllers) and I use keil.

I bought Arm Cortex-M3 Mini STM32 Dev Board +2.4'' TFT LCD Touchscreen

Not much info for people like me on internet, so I decided to start gathering some data.

There will be many mistakes, for which I apologize.

My hope is that guys like me will add data so that we can all learn.

I use library made by ST.

I bought J-link-ARM segger  - they are not expensive and I can not imagine not have it.

I uploaded simple small project of mine.

About Keil and STM32 library.

When loading program to micro controller you must set address for J-link.

 Click on ''Target Option'' button and pick Debug Tab -> Pick Cortex/J-link

and then Utilities tab -> pick J-link again and very important click settings and ADD button -> STM32F10x High density Flash

 ----------------------------------------

To add file to project double click on folder

than add header file info in stm32f10x_conf.h,

example:

#include ''CreatedByMe.h''

#include ''stm3210e_eval_lcd.h''

#include ''fonts.h''

-----------------------------------------------

How to run LCD

ST made LCD library too complicated in my opinion.

What I understand is that display module is composed of  LCD and Touch panel, two completely separate devices.

This particular LCD module act as RAM memory and can be write into by STM32.

RAM takes color of the pixel, and LCD register take info about what to with the pixel. And basically that is it.

To write to LCD RAM micro controller uses FSMC. I attached PDF which explains it.

User has to initiate FSMC, but this was already done by ST in STM3210E_LCD_Init function.

STM32 has to known memory address of  LCD, which is address of FSMC

#define LCD_BASE    ((uint32_t)(0x60000000 | 0x00000000))

 The only modification I had to in library was address of RAM and REGISTERS

#define LCD_BASE    ((uint32_t)(0x60000000 | 0x00000000))         - address of registers

typedef struct

{

  __IO uint16_t LCD_RAM;

} LCD_TypeDef;

#define LCD             ((LCD_TypeDef *) (LCD_BASE + 0x20000))      - color of pixels

typedef struct

{

  __IO uint16_t LCD_REG;

} LCD_TypeDefReg;

#define LCDREG             ((LCD_TypeDefReg *) (LCD_BASE))

I did this way so I don’t have to modify library too much.

So after initialization one can display pixel by sending data to LCD memory for registers and for data

So if you want make LCD clear with one color:

1. Wright LCD register with position X (LCD_WriteReg(LCD_REG_32, Xpos);)

2. Wright LCD register with position Y (LCD_WriteReg(LCD_REG_32, Ypos);)

3. Tell LCD to get color of pixel     (LCDREG->LCD_REG = LCD_REG_34;)

4. Send color of pixel to RAM   ( LCD->LCD_RAM = RGB_Code;)

In library following functions

LCD_Clear

LCD_SetCursor

LCD_WriteRAM_Prepare

LCD_WriteRAM

And that is basically it.

All LCD library functions just do above, of course on massive scale. This display has 76800 pixels ,so using already made functions make helps for example in sending characters.

Initialization of LCD:

 LCD_CtrlLinesConfig();  - General purpose pins setup

 LCD_FSMCConfig();  - controller that communicate with RAM

I only added in function LCD_CtrlLinesConfig(void)  ( to have backlight on)

                //LCD Reset

                GPIO_InitStructure.GPIO_Pin=GPIO_Pin_1;

                GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;

                GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;

                GPIO_Init(GPIOE, &GPIO_InitStructure);

                GPIO_SetBits(GPIOE,GPIO_Pin_1);                //NO reset

                //LCD Backlight

                GPIO_InitStructure.GPIO_Pin=GPIO_Pin_13;

                GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;

                GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;

                GPIO_Init(GPIOD, &GPIO_InitStructure);

                GPIO_SetBits(GPIOD,GPIO_Pin_13);//Backlight on