cancel
Showing results for 
Search instead for 
Did you mean: 

Tutorials, etc.

jprevard
Associate II
Posted on May 06, 2014 at 07:17

Is there a tutorial or lecture series for beginners working with a STM32F3 demo board? I have programmed simple project boards like Arduino, but not anything like the STM32 boards. I have tried to work backwards from the provided demo, but I'm not familiar with terms like GPIO, __IO, BSRR, etc. I realize these terms are fairly standard for C programming, but I guess what I am looking for is a tutorial on C programming based around the STM32 product. My goal is to create a signal similar to a square wave in which each cycle has a unique, predefined period.

11 REPLIES 11
Amel NASRI
ST Employee
Posted on May 06, 2014 at 16:05

Hi Justin,

GPIO, BSRR... this is related to the MCU.

You need first basic knowledge about microcontrollers, mainly the STM32F3.

There is a set of documentation related to STM32F3 on

http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1576/LN1531/PF252051#

.

You can use the examples found in 

http://www.st.com/web/en/catalog/tools/PF258144

and described in

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00068049.pdf

.

A quick answer, hope it will help you to start...

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

de_koepi
Associate II
Posted on May 06, 2014 at 17:36

There are plenty of ressources available on the net, simple overview articles like these:

http://www.bigmessowires.com/2011/10/27/cortex-m3-for-dummies-stm32-discovery-board/

On the other hand, it might be useful to take a look into the processor reference manual. There you can see very fast what/why/where GPIO is, and what BSRR/BRR are about. And how you have to use them. For STM32F1xx, take for example this:

http://www.st.com/web/en/resource/technical/document/reference_manual/CD00171190.pdf

Sure, it's about 1000 pages, but you don't need to read it all at once. Start with the parts that you need. Then the standard periphal library staarts making sense. Anyhow, some basic C knowledge is mandatory. In C, the platform doesn't matter. Take a short tour on C (there are these ''C for Dummys'' or ''Learn C in 21 days'' books available in the book stores), for example still on your computer. 

After that, the reference manual and the library start making sense very soon.
chen
Associate II
Posted on May 06, 2014 at 17:46

Hi

The reference manual is not a good 'tutorial' for using the STM32 peripherals.

It does not explain the basic operating ideas in a simple manner.

It just bombards you with details but the details you need are missing!

I am not advertising it but I have seen a couple of people recommend

 Joseph Yiu book :

http://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CEIQFjAC&url=http://books.google.com/books/about/The_Definitive_Guide_to_the_ARM_Cortex_M.html?id%3Dmb5d_xeINZEC&ei=xQJpU_PjGbLb7AaqrYD4Dg&usg=AFQjCNGdTxMUYqvmI-eOVgxW-UbmMZdbQQ&bvm=bv.66111022%2cd.ZGU

(I have not read it myself)

Posted on May 06, 2014 at 21:38

Learn C first, learn about micro-processors and architectures. Like

http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dstripbooks&field-keywords=John+L+Hennessy&rh=n:283155%2ck:John+L+Hennessy

, Patterson

Several books on embedded development. Like

http://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Dstripbooks&field-keywords=jack+ganssle&rh=n:283155%2ck:jack+ganssle

and

http://shop.oreilly.com/product/0636920017776.do

http://www.abebooks.com/servlet/BookDetailsPL?bi=12422234816&searchurl=an%3DJoseph%2BYiu%26amp%3bsts%3Dt

provide an alternate perspective from the assorted Technical Reference Manuals. ARM has a good selection of TRM and documentation, ST's covers the specifics about the peripherals they add to the core.

Not sure I've seen a STM32 specific book, they are several families which complicates the presentation. I've seen some books on the PIC32.

Several educational institutions are using the STM32, a couple of teachers/professors have written books on their specific course.

Geoff Brown's was a good one

http://www.cs.indiana.edu/~geobrown/book.pdf

and I seem to remember a Czech college had another one

For Assembler, I like Waldron it's a bit MIPS orientated but worth review. Mazadi is quite reasonable (eBook $10), as is Gibson, Hohl is Ok, seems to be a standard undergraduate text and consequently rather expensive.

For print books consider International Versions, from places like AbeBooks they are cheaper soft covers generally shipping out of India, or places like Alibris

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jprevard
Associate II
Posted on May 08, 2014 at 06:30

Wow! Thank you so much for all of the input. I was hoping for a ''Blinky'' to be included in the examples that came with the board, but it seems like they are all more complicated. I see at least one blinky for an F1 or VL or something in the suggestions you have given...i will try to adapt that over to my F3. I would need something bare bones like that if I want to teach myself how to use the board using just reading material (and these forums! lol).

Thanks again and let me know if you think of anything else!!
Posted on May 08, 2014 at 15:32

STM32F3-Discovery_FW_V1.0.0\Project\Peripheral_Examples\GPIO_IOToggle\main.c

LEDs on PE[8..15]

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 08, 2014 at 15:59

// STM32 LED Swoosh STM32F3 Discovery - sourcer32@gmail.com
#include ''stm32f30x.h''
/**************************************************************************************/
void RCC_Configuration(void)
{
/* --------------------------- System Clocks Configuration -----------------*/
/* GPIOE clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE, ENABLE);
}
/**************************************************************************************/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/*-------------------------- GPIO Configuration ----------------------------*/
/* GPIOE Configuration: Pins 8 .. 15 in output push-pull */
GPIO_InitStructure.GPIO_Pin =
GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 |
GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOE, &GPIO_InitStructure);
}
/**************************************************************************************/
volatile int SystemTick = 0;
#define TICK_RATE 1 // in milliseconds
void SysTick_Handler(void)
{
// Free running millisecond counter for timeouts
SystemTick += TICK_RATE; // 1 ms tick count
}
/**************************************************************************************/
int Sleep(int Delay)
{
int Start, Current;
Start = SystemTick;
do
{
// __WFI(); // Wait for interrupt (might break debugger)
Current = SystemTick;
}
while((Current - Start) < Delay);
return(Current - Start); // Estimate of time past
}
/**************************************************************************************/
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
SysTick_Config(SystemCoreClock / 1000); // 1 KHz tick (1 ms)
while(1) // Infinite Loop
{
const int swoosh[]= { 1, 2, 4, 8, 16, 32, 64, 128, 128, 64, 32, 16, 8, 4, 2, 1 };
static int i = 0;
int mask = swoosh[i];
i = (i + 1) & 0x0F;
if (mask & 1)
GPIO_SetBits(GPIOE, GPIO_Pin_8);
else
GPIO_ResetBits(GPIOE, GPIO_Pin_8);
if (mask & 2)
GPIO_SetBits(GPIOE, GPIO_Pin_9);
else
GPIO_ResetBits(GPIOE, GPIO_Pin_9);
if (mask & 4)
GPIO_SetBits(GPIOE, GPIO_Pin_10);
else
GPIO_ResetBits(GPIOE, GPIO_Pin_10);
if (mask & 8)
GPIO_SetBits(GPIOE, GPIO_Pin_11);
else
GPIO_ResetBits(GPIOE, GPIO_Pin_11);
if (mask & 16)
GPIO_SetBits(GPIOE, GPIO_Pin_12);
else
GPIO_ResetBits(GPIOE, GPIO_Pin_12);
if (mask & 32)
GPIO_SetBits(GPIOE, GPIO_Pin_13);
else
GPIO_ResetBits(GPIOE, GPIO_Pin_13);
if (mask & 64)
GPIO_SetBits(GPIOE, GPIO_Pin_14);
else
GPIO_ResetBits(GPIOE, GPIO_Pin_14);
if (mask & 128)
GPIO_SetBits(GPIOE, GPIO_Pin_15);
else
GPIO_ResetBits(GPIOE, GPIO_Pin_15);
Sleep(100); // 100 ms
}
}
//******************************************************************************
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf(''Wrong parameters value: file %s on line %d

'', file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jprevard
Associate II
Posted on May 09, 2014 at 07:56

Awesome! Thx clive1 I will hook up some LEDs this weekend. I did happen to look at the GPIO Toggle example under the scope. Best I could tell it was horizontally ''shaky'' and about 40MHz (I was looking at PE14 and PE15). Does that sound like correct behavior? I am looking for a square wave to start and then modify that a bit once I figure that out, but the BSRR / BRR toggling seems to create a sinusoidal signal.

Here is what I have otherwise done and where I am getting errors:

I start with a main.c copied from an example or the main demo

I look at it's includes and all of it's include's includes

I add all of those files to the project (for some reason the stm32f30x_rcc.h was not originally included, or I just missed it...so I added it myself to get rid of an error)

After all files that are referenced are added I ''Make'' the project (not sure diff b/t make and rebuild)

I get the error shown in the attached file. Something about __nounwind__DSB and Thumb mode.

Make any sense??

________________

Attachments :

nounwindError.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0cW&d=%2Fa%2F0X0000000bbK%2FaeR7ZEIAeggcfaPoGpJ.XtdUHsLAHs.nVMcB5hu549I&asPdf=false
jprevard
Associate II
Posted on May 09, 2014 at 08:07

Okay, after selecting my board (STM32F303) from Options and then selecting Make again I get the errors shown in the attached file.

________________

Attachments :

newError.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0cM&d=%2Fa%2F0X0000000bbI%2FDjKrOiqyHAbxLjQ18TjuBO3scPGLVKrH_YylT6OeXiw&asPdf=false