cancel
Showing results for 
Search instead for 
Did you mean: 

Transitioning from STM32 discovery to custom board (clock settings?)

boris2
Associate II
Posted on September 10, 2014 at 16:44

I have developed a simple application to test GPIOs, SPI, UART on the STM32F4 Discovery dev board (a modified demo application from the included Discovery demo V1.1.0). The demo application uses the STM32F4xx_StdPeriph_Driver.

I'm now trying to transition this code to a custom PCB that has a very similar STM32F427VIT6 processor, but a 19.2MHz external OSC instead of a 8MHz on the Discovery board.

I've changed the target device in compiler settings.

Could somebody help me with changing the clock frequency and the required PLL settings in order for my firmware to work with this new device. I'm just not sure where the clock configuration is set in code, and what the ''speed limits'' are. The code is just for hardware verification so ''max speed'' is not required.

I'm using IAR embedded workbench IDE.

I've tried generating a new project with the STM32cube application, and it does work, compile, LEDs blink, clocks are set correctly. Problem is that the STM32cube application includes a HAL driver library which is not easily compatible with the code I already have written using the STM32F4xx_StdPeriph_Driver.

Thank you,

Boris.
4 REPLIES 4
Posted on September 10, 2014 at 17:00

I'm not using HAL/CUBE, for the Standard Peripheral Library the code you need is in system_stm32f4xx.c

The limits of the PLL are described in the Reference Manual, you should review these. They do have an Excel sheet to compute these things, but it's not that difficult.

The key fact probably is the comparison frequency for the PLL should be in the 1-2 MHz range.

I'd suggest a PLL_M of 18 for a fComp of 1.0667 MHz, a PLL_N of 315 for a processor speed of 168 MHz

Alternatively 19, 332 for 167.7474 MHz
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
boris2
Associate II
Posted on September 10, 2014 at 21:15

Thanks for the reply. I used the ST excel clock configuration tool and got PLL M = 17, N=340, APB1 prescaler  = 1, APB2 prescaler =1.

Having setup a UART1 to run at 57600 bps I get a UART rate of ~139kHz on the scope. 2.4 times higher than what it should be. Is there something in the UART librar itself I need to change....? Does it matter what the APB2 clock result is, the UART library adjusts the baud rate based on its setting?

Posted on September 10, 2014 at 21:53

The part is not rated to run at 192 MHz!?

For the baud rate it suggests the define for HSE_VALUE is wrong, ie 8000000 and not 19200000
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
boris2
Associate II
Posted on September 11, 2014 at 16:32

How did the 192MHz number come up?

I've included a screen shot of the clock config tool.

Shouldn't the HSE_VALUE match the actual oscillator frequency or you are saying that the UART library only expects a 8MHz external OSC?

0690X00000603IMQAY.jpg