cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with STM32F072RB and Cube Library

nicolas2
Associate II
Posted on September 08, 2016 at 20:47

Hello guys,

I wanted to make a new project for my STM32F072RB using the Cube Library.

I'm programming in Eclipse with GNU ARM Eclipse plugin, ARM GCC compiler and OpenOCD together with an ST-Link V2.

When I use the STD Peripheral Library, everything works fine. I can program my code, compile and debug it without any issue.

Now I wanted to port my code to Cube. So I configured everything in CubeMX and compiled the code without errors.

When I use the internal 8 MHz clock, the code will flash and run. But when I try to enable the HSE, PLL or the internal 48 MHz crystal, I get an error. It seems that the controller locks up completely because I can't access the chip via SWD. I have to reset the chip with the ST-Link Utility tool to get access again. So seems to be an issue with the clock configuration.

Is this a known bug of the Cube Library? As I wrote before, it works perfectly with the STD Periph Lib!

I also have some STM32F103RB/C Chips and they work nicely with the Cube Library. So the only problem is the combination of STM32F0 and Cube lib.

Does someone know what the problem is? I'd appreciate any helpful information.

Best regards

Nicolas Dammin

#bug #cube #stm32f0
6 REPLIES 6
markb
Associate II
Posted on September 08, 2016 at 21:50

Hi,

I have just created a cube project for a STM32F072 with an 8MHz crystal and it works OK. I will attach the ioc file for your inspection.

Cheers,

Mark

________________

Attachments :

pb4-vmon.ioc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hthv&d=%2Fa%2F0X0000000aW1%2FSpr2N6b4Dm00NC5vkbLY0ftBeJ8QttxvpAugVHmtZtg&asPdf=false
nicolas2
Associate II
Posted on September 09, 2016 at 11:16

hey Mark,

thanks for your reply. Sadly, I couldn't login to the Forum yesterday.

The CubeMX project setup looks pretty much the same as mine does. Which IDE and compiler do you use? Could you maybe send your complete C project? If there is no bug in the Cube Library code, I absolutely have no idea why it is not working for my Micro. It is definitely not broken, 'cause it works with the STD Lib.

regards

Nico

mark239955_stm1
Associate II
Posted on September 09, 2016 at 13:20

SWD is mapped to GPIOA.13 and A.14 AF0 by default; if you are changing the GPIOA->AFRH register for other pins, you may also be accidentally changing the fields for the SWD pins.  If you change either field to anything but 0, SWD will cease functioning immediately.

I suggest that you review your code to look for anything that might change GPIOA->AFRH, and if you can't find it with a review then some single-stepping in the debugger may be helpful.

nicolas2
Associate II
Posted on September 09, 2016 at 15:05

IT WORKS!!!

I checked all files and the problem was the ld file. I used the automatically generated .ld files from GNU ARM Eclipse because they worked fine with the STM32F103 in the past. But for the STM32F072RBT6 I had to use the STM32F072RBTx_FLASH.ld file and bingo! Now I can use the PLL and USB =)

Thank you very much Mark!

markb
Associate II
Posted on September 09, 2016 at 15:15

Great, glad it's working now.

FYI, that .ld file was created by the cube for the SW4STM32 ide.

Cheers,

Mark