Getting started with the STM32F072B-Discovery

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

charlesrwest
Posts: 38
Joined: Sat Jan 10, 2015 10:12 pm
Has thanked: 1 time
Been thanked: 1 time

Getting started with the STM32F072B-Discovery

Post by charlesrwest »

Hello!

I'm trying to get started with the STM32F072B & ChibiOS. I've run into a few issues and was hoping to get some advice.

I noticed that there is a demo for the STM32F051. I tried flashing it to my discovery board (using the ST-Link program from https://github.com/texane/stlink over the st-link interface of the board). The flashing software fails sometimes, but claimed that it wrote ch.bin to the device successfully (writing to address 0x08000000). However, that just cause the board to freeze and when I reset it then it goes back to its original behaviour (which is not the same as the expected blinking from the demo).

If I may ask:

What modifications do I need to make the STM32F051 Discover demo work for the STM32F072? I noticed that the linker files for the STMF030 and the STMF051 were identical except for one comment line.

Am I flashing to the right address?

Do you have any other general advice for someone trying to get ChibiOS running on an Discover board?

Thanks,
Charlie West
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Getting started with the STM32F072B-Discovery

Post by Giovanni »

Hi,

ChibiOS version 3.0 contains already a demo for the STM32F072-Discovery (and all other discovery boards as well), consider updating to the latest version (3.0.0p6).

You may also give ChibiStudio a try, it contains both 3.0.x and 2.6.x ChibiOS and all demos.

Giovanni
charlesrwest
Posts: 38
Joined: Sat Jan 10, 2015 10:12 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Getting started with the STM32F072B-Discovery

Post by charlesrwest »

Hey Giovanni,

Thanks for the really fast response. 3.0 is close to being officially released but hasn't yet been, right? I cloned the Git repository and the demo there worked very well.

If I may ask, should I clone the git repository or use one of the previews? Is the git master branch likely to have things that are broken/in an unready state?

Thanks again,
Charlie
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Getting started with the STM32F072B-Discovery

Post by Giovanni »

Hi,

Usually the repository is never really "broken", most changes are incremental. Big changes are preceeded by warnings on the forum. Preview 6 is almost final, the release will happen within July, it is mostly about regenerating all reports and get the new web site started, there are no changes planned before 3.0.0 final.

Giovanni
charlesrwest
Posts: 38
Joined: Sat Jan 10, 2015 10:12 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Getting started with the STM32F072B-Discovery

Post by charlesrwest »

Awesome. I will keep working with the master branch then. This will be really cool. Thanks again.
DGW
Posts: 47
Joined: Fri May 30, 2014 9:14 am

Re: Getting started with the STM32F072B-Discovery

Post by DGW »

Good afternoon.
For STM32F072V-Disco I want to write a small project, but want to use an external crystal (8 MHz). The file mcuconf.h prescribed:

Code: Select all

#define STM32_NO_INIT                       FALSE
#define STM32_PVD_ENABLE                    FALSE
#define STM32_PLS                           STM32_PLS_LEV0
#define STM32_HSI_ENABLED                   TRUE
#define STM32_HSI14_ENABLED                 TRUE
#define STM32_HSI48_ENABLED                 FALSE
#define STM32_LSI_ENABLED                   TRUE
#define STM32_HSE_ENABLED                   TRUE //FALSE
#define STM32_LSE_ENABLED                   FALSE
#define STM32_SW                            STM32_SW_PLL
#define STM32_PLLSRC                        STM32_PLLSRC_HSE //STM32_PLLSRC_HSI_DIV2
#define STM32_PREDIV_VALUE                  1
#define STM32_PLLMUL_VALUE                  6 //12
#define STM32_HPRE                          STM32_HPRE_DIV1
#define STM32_PPRE                          STM32_PPRE_DIV1
#define STM32_ADCSW                         STM32_ADCSW_HSI14
#define STM32_ADCPRE                        STM32_ADCPRE_DIV4
#define STM32_MCOSEL                        STM32_MCOSEL_NOCLOCK
#define STM32_ADCPRE                        STM32_ADCPRE_DIV4
#define STM32_ADCSW                         STM32_ADCSW_HSI14
//#define STM32_USBSW                         STM32_USBSW_HSI48
#define STM32_CECSW                         STM32_CECSW_HSI
#define STM32_I2C1SW                        STM32_I2C1SW_HSI
//#define STM32_I2C1SW                      STM32_I2C1SW_SYSCLK
#define STM32_USART1SW                      STM32_USART1SW_PCLK
#define STM32_RTCSEL                        STM32_RTCSEL_LSI


Launch projects and it hangs in the function stm32_clock_init (void). What am i doing wrong? Thanks for the help.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Getting started with the STM32F072B-Discovery

Post by Giovanni »

With the above settings the project should not even compile. You have some parameters out of limits.

Try:

Code: Select all

#define STM32_NO_INIT                       FALSE
#define STM32_PVD_ENABLE                    FALSE
#define STM32_PLS                           STM32_PLS_LEV0
#define STM32_HSI_ENABLED                   TRUE
#define STM32_HSI14_ENABLED                 TRUE
#define STM32_HSI48_ENABLED                 FALSE
#define STM32_LSI_ENABLED                   TRUE
#define STM32_HSE_ENABLED                   TRUE
#define STM32_LSE_ENABLED                   FALSE
#define STM32_SW                            STM32_SW_PLL
#define STM32_PLLSRC                        STM32_PLLSRC_HSE
#define STM32_PREDIV_VALUE                  2
#define STM32_PLLMUL_VALUE                  12
#define STM32_HPRE                          STM32_HPRE_DIV1
#define STM32_PPRE                          STM32_PPRE_DIV1
#define STM32_ADCSW                         STM32_ADCSW_HSI14
#define STM32_ADCPRE                        STM32_ADCPRE_DIV4
#define STM32_MCOSEL                        STM32_MCOSEL_NOCLOCK
#define STM32_ADCPRE                        STM32_ADCPRE_DIV4
#define STM32_ADCSW                         STM32_ADCSW_HSI14
#define STM32_USBSW                         STM32_USBSW_HSI48
#define STM32_CECSW                         STM32_CECSW_HSI
#define STM32_I2C1SW                        STM32_I2C1SW_HSI
#define STM32_USART1SW                      STM32_USART1SW_PCLK
#define STM32_RTCSEL                        STM32_RTCSEL_LSI


You also have to put 8000000U as frequency in board.h.

Giovanni
DGW
Posts: 47
Joined: Fri May 30, 2014 9:14 am

Re: Getting started with the STM32F072B-Discovery

Post by DGW »

Did you have written, it hangs on the line
while (!(RCC->CR & RCC_CR_HSERDY))
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Getting started with the STM32F072B-Discovery

Post by Giovanni »

That could mean that the oscillator does not start, are there solder bridges to remove on the board?

Giovanni
DGW
Posts: 47
Joined: Fri May 30, 2014 9:14 am

Re: Getting started with the STM32F072B-Discovery

Post by DGW »

It earned as soon as board.h removed #define STM32_HSE_BYPASS
Post Reply