cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 discovery - newbie

freya17365
Associate II
Posted on September 08, 2015 at 09:22

Hi to all,

I wanted to start a project using STM32 MCU and I would ask where can I find the first basic instruction.

I have a STM32F0 board, but I don't know how to interface with pc. I downloaded ST_LINK, and I expect to find some COM port on my pc, but nothing happened.

Any suggestions?

Thank you

Freya

#'getting-started'-osx
9 REPLIES 9
leon355
Associate II
Posted on September 08, 2015 at 10:37

What happens when the board is connected to the PC?

Nesrine M_O
Lead II
Posted on September 08, 2015 at 11:56

Hi Freya,

1)To run and develop any firmware applications on your STM32F0-DISCOVERY board, the minimum requirements are as follows:

• Windows PC (2000, XP, Vista, 7) 

• 'USB type A to Mini-B' cable, used to power the board (through USB connector CN1) from host PC and connect to the embedded ST-LINK/V2 for debugging and programming.

2)Development toolchains supporting the STM32F0 DISCOVERY

• Altium®, TASKINGâ„¢ VX-toolset 

• ARM®, Atollic TrueSTUDIO®

• ARâ„¢, EWARM (IAR Embedded Workbench®) 

• Keil™, MDK-ARM™

3) ''I downloaded ST_LINK, and I expect to find some COM port on my pc, but nothing happened.''

Detecting board is not to find COM port on your PC, I'd highly recommend you to have a look for example to the  

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

For more information on the STM32F0 Discovery kit and for demonstration software, visit

-Syrine –

adam239955
Associate II
Posted on September 08, 2015 at 12:15

Hi,

also take care with the USB ports, I found that using the USB 2.0 ports gave a more stable experience with ST-Link utility + driver. So try all the USB ports in your PC.

You should also make sure that you have all the required drivers.

In my project we use GNU ARM Eclipse with OpenOCD on a Win7 PC workstation to develop for the STM32F3-Discovery board:

http://gnuarmeclipse.livius.net/blog/

Adam

Posted on September 08, 2015 at 17:06

The Virtual COM port is supported by the NUCLEO boards, not the DISCO ones.

The ST-LINK on the DISCO provides debug connectivity, using drivers in Keil, IAR, etc. On the non Cortex-M0 boards the Serial Wire Viewer (SVW) provides a debug communications stream, but might require the Solder Bridge (SB) be made for the PB3 connection.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
freya17365
Associate II
Posted on September 09, 2015 at 14:23

Thank you to all,

I installed again STLink and now it seems board is found (see annex) and I am trying to install and configure emIDE to develop programs.

Now I have to solve some other problems such as:

- How to send programs to board and verify they are correctly transferred

- How can I send/receive data to/from board during program execution

I also downloaded and started to study documentation and it is more or less 3.000 pages. Any hint on where start first?

Thank you

Freya

________________

Attachments :

Immagine2.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzqm&d=%2Fa%2F0X0000000bQL%2FsbBfNLgXIZHS5UcvDiJkXrgq6FL__u_haVTHfQ8frcU&asPdf=false
Posted on September 09, 2015 at 14:53

Do you come to this with any other electronics or microprocessor experience?

For the reference manual, skim it, understand what detail is where, then focus on the Clocks, the Pins, and then the Peripherals, starting with the ones you plan to use first. Understand what details are in the Data Manual, and what's in the Programming Manual.

For the core get one of Joseph Yiu's books on the Cortex-Mx parts, the M0 one being ideal here.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
freya17365
Associate II
Posted on September 09, 2015 at 15:31

Yes, I come from Atmel SAM MCU's where I had a programming IDE, a tool to interface (send program and I/O communication) using UART port and JTAG for debugging.

I would like to recreate something like with STM's MCU in order to develop and test programs on board.

I have no problem to study registry, peripherals and so on, but first of all I need to interface with board.

At present I am able only to power up the board and this is my problem.

Freya

Posted on September 09, 2015 at 18:06

I think you're going to have to find yourself some USART pins, and wire up a SiLabs or FTDI USB-to-CMOS Serial type dongle.

/* USART2 PA.2 Tx, PA.3 Rx STM32F0-Discovery sourcer32@gmail.com */
#include ''stm32f0xx.h''
#include ''stm32f0_discovery.h''
int main(void)
{
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_1);
/* Configure USART2 pins: Rx and Tx ----------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART2, &USART_InitStructure);
USART_Cmd(USART2,ENABLE);
while(1)
{
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
USART_SendData(USART2, 'X');
}
}

Through Keil you can retarget the printf functionality

//******************************************************************************
// Hosting of stdio functionality through USART2
//******************************************************************************
#include <
rt_misc.h
>
#pragma import(__use_no_semihosting_swi)
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f)
{
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
USART_SendData(USART2, ch);
return(ch);
}
int fgetc(FILE *f)
{
char ch;
while(USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET);
ch = USART_ReceiveData(USART2);
return((int)ch);
}
int ferror(FILE *f)
{
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch)
{
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
USART_SendData(USART2, ch);
}
void _sys_exit(int return_code)
{
label: goto label; /* endless loop */
}
/**************************************************************************************/

The alternative with a Virtual COM port implementation would be the NUCLEO boards, most of which have PA2/PA3 associated with USART2
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
freya17365
Associate II
Posted on September 11, 2015 at 08:13

Hi,

now I am ready!

I installed STLink009 that contains only drivers and now I installed also STLink004 that contain the utility program.

So now I have an IDE and a program to deploy on board.

Thnak you for your help

Freya