cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429I-DISCO and XTAL X3 8MHz

ricardodm
Associate II
Posted on October 21, 2014 at 23:30

Hi,

Its my first time here! I have a STM32F429I-DISCO, original from factory. I used the STM32CubeMX with STM32Cube_FW_F4_V1.3.0 to build a code. I selected ''new project\board selector\Type of Board: Discovery\Series: STM32F4\Board List: STM32F429iDISCOVERY'' In the Clock Configurations, all items seemed OK. If I properly understood the manual, the HSE is used for external xtal. In this kit, this crystal is the X3... A 8MHz xtal.

I put a screenshot of

STM32CubeMX

Clock Configurations

here. I built a very simple code to the first test of my kit.


/* USER CODE BEGIN 3 */

BSP_LED_Init(LED3);


/* Infinite loop */

while (1)

{

__asm(

''ldr r1, =0x40021800;''

''ldr r3, [r1,#20];'' 

''loop:;'' 

''eors r3, 0x2000;'' 

''str r3, [r1,#20];''

''b loop;''

);

}

/* USER CODE END 3 */

This code will switch the output port PG13, referring to LED3. I could see a waveform with these following time base: ____ _... ..._| |____| +---50nS--+ Until this point everything seemed OK. However, when I pulled the X3 crystal, to my surprise, the kit remained operational!!! I can not understand how this is possible!!! Would you could help me with this? Now, I'm not even sure if the kit is running at the correct frequency of 180MHz!!!
9 REPLIES 9
Posted on October 22, 2014 at 00:28

The part does not need an external crystal/clock to run. The part starts using the 16 MHz HSI, and is likely to remain using that if the external source or the PLL do not start. Review the fail-over code paths in the start up functions. SystemInit()?

You can export the internal clocks via the MCO1 pin (PA8)
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
ricardodm
Associate II
Posted on October 22, 2014 at 01:33

Thank you for helping-me Clive

I know that the STM32F429ZIT microcontroller, does not need an external crystal to work, however I setup the STM32CubeMX tools, for it generate a code using the Crystal Factory X3 8MHz.

You saw the screenshot that I put in the topic?

You can check that the code was configured to use this crystal by the HSE.

There was not any error after the compilation!

I have not found SystemInit()

Follows below the initialization routine of the system clock:


void SystemClock_Config(void)

{

RCC_OscInitTypeDef RCC_OscInitStruct;

RCC_ClkInitTypeDef RCC_ClkInitStruct;


__PWR_CLK_ENABLE();


__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);


RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

RCC_OscInitStruct.HSEState = RCC_HSE_ON;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLM = 8;

RCC_OscInitStruct.PLL.PLLN = 360;

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

RCC_OscInitStruct.PLL.PLLQ = 7;

HAL_RCC_OscConfig(&RCC_OscInitStruct);


HAL_PWREx_ActivateOverDrive();


RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|

RCC_CLOCKTYPE_PCLK1|

RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);

}

I'm not sure if you understood my problem...

I configured the application supplied by ST, to generate one code for this kit.

To the microcontroller use the crystal, that the manufacturer place in this kit, and did not work this way.

The program STM32CubeMX generated all the code and I did not modified anything! Why not worked as expected?!

Posted on October 22, 2014 at 03:04

I'm not sure if you understood my problem...

This is indeed possible, I'm looking at the issue of why the part continues to clock, and I'm suggesting it's failing-over to a different source when your desired configuration is unworkable. What status does HAL_RCC_OscConfig() return? What do the RCC registers contain in the two conditions?
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
ricardodm
Associate II
Posted on October 23, 2014 at 01:16

I'm not sure if I made the right way, but...

I

performed in debug mode and after that went through

HAL_RCC_OscConfig(&RCC_OscInitStruct);

I captured the following variables:

Name : RCC_OscInitStruct

       Details:{OscillatorType = 1,

                HSEState = 1,

                LSEState = 0,

                HSIState = 8192,

                HSICalibrationValue = 4294967289,

                LSIState = 1073879040,

                PLL = {PLLState = 2,

                       PLLSource = 4194304,

                       PLLM = 6,

                       PLLN = 300,

                       PLLP = 2,

                       PLLQ = 8}}

Is that what you need?

I

f I did something wrong, please tell me what I have to do and how!

Posted on October 23, 2014 at 02:17

Those values don't seem to jive with those you passed in.

I was looking for the status code returned :

printf(''Status:%u\n'', (unsigned)HAL_RCC_OscConfig(&RCC_OscInitStruct));

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on October 23, 2014 at 02:45

printf(''%08X CFGR
'', RCC->CFGR);
printf(''%08X PLLCFGR
'', RCC->PLLCFGR);
printf(''%08X CR
'', RCC->CR);
printf(''%08X CSR
'', RCC->CSR);
printf(''%08X BDCR
'', RCC->BDCR);
printf(''%08X PWR
'', PWR->CR);

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
ricardodm
Associate II
Posted on October 23, 2014 at 18:28

Dear Clive,

first: You're right... its not the same config...

I was testing other frequencies, and forgot to return to the previous.

.. Now its all the same old one. second: Sorry me about my ignorance...

I know that my doubts are doubts beginner...

Clive,

all my 30 years of practice with microprocessors and microcontrollers have been in machine language</span>...

Now, due to the complexity of the ARM, I sought the help in C language! Sorry me about this!!

G

o ahead

... CODE:


void SystemClock_Config(void)

{

RCC_ClkInitTypeDef RCC_ClkInitStruct;

RCC_OscInitTypeDef RCC_OscInitStruct;


__PWR_CLK_ENABLE();


__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);


RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

RCC_OscInitStruct.HSEState = RCC_HSE_ON;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLM = 8;

RCC_OscInitStruct.PLL.PLLN = 360; 

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

RCC_OscInitStruct.PLL.PLLQ = 8;

//RCC_OscInitStruct.PLL.PLLQ = 4;

HAL_RCC_OscConfig(&RCC_OscInitStruct);


HAL_PWREx_ActivateOverDrive();


RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|

RCC_CLOCKTYPE_PCLK1|

RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);


printf(''%08X CFGR
'', RCC->CFGR);

printf(''%08X PLLCFGR
'', RCC->PLLCFGR);

printf(''%08X CR
'', RCC->CR);

printf(''%08X CSR
'', RCC->CSR);

printf(''%08X BDCR
'', RCC->BDCR);

printf(''%08X PWR
'', PWR->CR);

}

This implementation generated the following warning!

20:39:13 **** Incremental Build of configuration Debug for project STM32F429i ****
Info: Internal Builder is used for build
arm-atollic-eabi-gcc -c -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=gnu90 -DHSE_VALUE=8000000 -DUSE_STM32F429I_DISCO -DSTM32F42_43xxx -DUSE_STDPERIPH_DRIVER -I../src -I..\Libraries\CMSIS\Include -I..\Libraries\Device\ST\STM32F4xx\Include -I..\Libraries\STM32F4xx_StdPeriph_Driver\inc -I..\Utilities\Common -I..\Utilities\STM32F429I-Discovery -O0 -ffunction-sections -fdata-sections -g -Wall -o src\system_stm32f4xx.o ..\src\system_stm32f4xx.c 
..\src\system_stm32f4xx.c: In function 'SystemInit':
..\src\system_stm32f4xx.c:206:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
..\src\system_stm32f4xx.c:206:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
..\src\system_stm32f4xx.c:207:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
..\src\system_stm32f4xx.c:207:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
..\src\system_stm32f4xx.c:208:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
..\src\system_stm32f4xx.c:208:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
..\src\system_stm32f4xx.c:209:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
..\src\system_stm32f4xx.c:209:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
..\src\system_stm32f4xx.c:210:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
..\src\system_stm32f4xx.c:210:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
..\src\system_stm32f4xx.c:211:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
..\src\system_stm32f4xx.c:211:1: warning: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
arm-atollic-eabi-gcc src\tiny_printf.o src\system_stm32f4xx.o src\stm32f4xx_it.o src\startup_stm32f429x.o src\main.o Utilities\STM32F429I-Discovery\stm32f429i_discovery_sdram.o Utilities\STM32F429I-Discovery\stm32f429i_discovery_lcd.o Utilities\STM32F429I-Discovery\stm32f429i_discovery_l3gdo Utilities\STM32F429I-Discovery\stm32f429i_discovery_ioe.o Utilities\STM32F429I-Discovery\stm32f429i_discovery_i2c_ee.o Utilities\STM32F429I-Discovery\stm32f429i_discovery.o Utilities\Common\lcd_log.o Utilities\Common\fonts.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_spi.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_sdio.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_sai.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rtc.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rng.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_pwr.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_ltdc.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_iwdg.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_i2c.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_hash_sha1.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_hash_md5.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_hash.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_fmc.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_flash.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dma2d.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dma.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dcmi.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dbgmcu.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dac.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp_tdes.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp_des.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp_aes.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_crc.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_can.o Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_adc.o Libraries\STM32F4xx_StdPeriph_Driver\src\misc.o -o STM32F429i.elf -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -T..\stm32f4_flash.ld -Wl,--start-group -lc -lm -Wl,--end-group -static -Wl,-cref,-u,Reset_Handler -Wl,-Map=STM32F429i.map -Wl,--gc-sections -Wl,--defsym=malloc_getpagesize_P=0x1000 
L:\TrueSTUDIO\ide\jre\bin\java -jar L:\TrueSTUDIO\Tools\arm-atollic-reports.jar convert hex sizeinfo STM32F429i.elf 
Generate build reports...
Converting build output to hex
Converting build output to hex done
Print size information
text data bss dec hex filename
4040 20 1064 5124 1404 STM32F429i.elf
Print size information done
Generate build reports done
20:39:17 Build Finished (took 4s.0ms)

Is

this correct, or I need fix something?

ricardodm
Associate II
Posted on October 24, 2014 at 01:39

dear Clive, with the help of my ''friend'' google and some time, I got the following solution:

#include <
stdio.h
> // to printf function and...
#include <
inttypes.h
> // use C99 format specifiers: ''%'' PRIu32 ''
''
void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
__PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 8; 
RCC_OscInitStruct.PLL.PLLN = 360; 
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 8;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
HAL_PWREx_ActivateOverDrive();
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|
RCC_CLOCKTYPE_PCLK1|
RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
printf(''%08'' PRIu32 ''CFGR
'', RCC->CFGR);
printf(''%08'' PRIu32 ''PLLCFGR
'', RCC->PLLCFGR);
printf(''%08'' PRIu32 ''CR
'', RCC->CR);
printf(''%08'' PRIu32 ''CSR
'', RCC->CSR);
printf(''%08'' PRIu32 ''BDCR
'', RCC->BDCR);
printf(''%08'' PRIu32 ''PWR
'', PWR->CR);
}

...no more warning, but I still have beginner doubts, such as:

I'm not sure if these changes, are correct!

And I do not know how to see the result of printf function!

Sorry me again!
Posted on October 24, 2014 at 03:03

They made me learn C and PASCAL in college 28 years ago, and I was doing assembler and machine language stuff before that, and since.

Can't help you much with Atollic and Cube, my GNU/GCC platform of choice is Yagarto, but the semihosting/retargetting of printf to a USART or SWV (serial wire viewer - debug communication channel) needs some specific code.

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/USART_printf%20not%20working%20on%20STM323221G_eval%20via%20GNU_ARM_GCC&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46...

[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/STM32F4-Discovery%20Updated%20Libraries%20wMakefiles&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=130]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Discovery%2FSTM32F4-Discovery%20Updated%20Libraries%20wMakefiles&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=130

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..