/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / 'RCC_GetSYSCLKSource' never becomes 0x08

Username:     
Password:     
             

Forum

# 1   2012-01-17 11:54:35 'RCC_GetSYSCLKSource' never becomes 0x08

MartijnK
New member
Registered: 2012-01-17
Posts: 2

'RCC_GetSYSCLKSource' never becomes 0x08

Hello,

I have used ride for a few years now. Recently ,I moved to a new version of ride because my computer crashed. Now, I,m using XP professional instead of vista, which I used before. Because I moved to the new version of ride, I could not use precompiled libraries anymore, so I added all the st-libraries to my main-file and a few header files ('controller2.h' , ''controller2.c'' and 'spi_flash.h'). I use microcontroller : stm32f103vbt6.
I use the ''STM32Lib-v203'''- library.

The main file begins as follows:

#include "libraries/spi_flash.h"
#include "libraries/controller2.h"
#include "libraries/stm32f10x_map.h"
#include "libraries/stm32f10x_can.h"
#include "libraries/stm32f10x_gpio.h"
#include "libraries/stm32f10x_nvic.h"
#include "libraries/stm32f10x_flash.h"
#include "libraries/stm32f10x_dma.h"
#include "libraries/stm32f10x_dac.h"
#include "libraries/stm32f10x_pwr.h"
#include "libraries/stm32f10x_rtc.h"
#include "libraries/stm32f10x_usart.h"
#include "libraries/stm32f10x_spi.h"
#include "libraries/stm32f10x_adc.h"
#include "libraries/stm32f10x_rcc.h"
#include "libraries/stm32f10x_bkp.h"
#include "libraries/stm32f10x_crc.h"
#include "libraries/stm32f10x_fsmc.h"
#include "libraries/stm32f10x_i2c.h"
#include "libraries/stm32f10x_sdio.h"
#include "libraries/stm32f10x_systick.h"
#include "libraries/stm32f10x_dbgmcu.h"
#include "libraries/stm32f10x_iwdg.h"
#include "libraries/stm32f10x_tim.h"

The files "spi_flash.h'' and ''controller2.h" are self-written files. The rest are st-header files.

The begin of "spi_flash.h" looks like:

#include "stm32f10x_map.h"
#include "stm32f10x_can.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_nvic.h"
#include "stm32f10x_flash.h"
#include "stm32f10x_dma.h"
#include "stm32f10x_dac.h"
#include "stm32f10x_pwr.h"
#include "stm32f10x_rtc.h"
#include "stm32f10x_type.h"
#include "stm32f10x_usart.h"
#include "stm32f10x_spi.h"
#include "stm32f10x_adc.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_bkp.h"
#include "stm32f10x_fsmc.h"
#include "stm32f10x_i2c.h"
#include "stm32f10x_sdio.h"
#include "stm32f10x_systick.h"
#include "stm32f10x_dbgmcu.h"
#include "stm32f10x_iwdg.h"
#include "stm32f10x_tim.h"

'controller.h'' has no header files.

The begin of another function called "controller.c" looks like:

#include "spi_flash.h"
#include "controller2.h"
//#include "stm32f10x_lib.h"
#include "stm32f10x_map.h"
#include "stm32f10x_can.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_nvic.h"
#include "stm32f10x_flash.h"
#include "stm32f10x_dma.h"
#include "stm32f10x_dac.h"
#include "stm32f10x_pwr.h"
#include "stm32f10x_rtc.h"
#include "stm32f10x_type.h"
#include "stm32f10x_usart.h"
#include "stm32f10x_spi.h"
#include "stm32f10x_adc.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_bkp.h"
#include "stm32f10x_fsmc.h"
#include "stm32f10x_i2c.h"
#include "stm32f10x_sdio.h"
#include "stm32f10x_systick.h"
#include "stm32f10x_dbgmcu.h"
#include "stm32f10x_iwdg.h"
#include "stm32f10x_tim.h"


#include "stm32f10x_can.c"
#include "stm32f10x_gpio.c"
#include "stm32f10x_nvic.c"
#include "stm32f10x_flash.c"
#include "stm32f10x_dma.c"
#include "stm32f10x_dac.c"
#include "stm32f10x_pwr.c"
#include "stm32f10x_rtc.c"
#include "stm32f10x_usart.c"
#include "stm32f10x_spi.c"
#include "stm32f10x_adc.c"
#include "stm32f10x_rcc.c"
#include "stm32f10x_bkp.c"
#include "stm32f10x_fsmc.c"
#include "stm32f10x_i2c.c"
#include "stm32f10x_sdio.c"
#include "stm32f10x_systick.c"
#include "stm32f10x_dbgmcu.c"
#include "stm32f10x_iwdg.c"
#include "stm32f10x_tim.c"


In the main file, the function ''MUCB_Configure(57600);'' of "'controller.h" is called at the beginning. This function configures multiple peripherals. It calls e.g. the function ''void RCC_Configuration(void)'' by itself. This function configures the clocks. The content of the function is:

void RCC_Configuration(void)
{
  /* RCC system reset(for debug purpose) */
  RCC_DeInit();

  /* Enable HSE */
  RCC_HSEConfig(RCC_HSE_ON);

  /* Wait till HSE is ready */
  HSEStartUpStatus = RCC_WaitForHSEStartUp();

  if (HSEStartUpStatus == SUCCESS)
  {
    /* Enable Prefetch Buffer */
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

    /* Flash 2 wait state */
    FLASH_SetLatency(FLASH_Latency_2);

    /* HCLK = SYSCLK */
    RCC_HCLKConfig(RCC_SYSCLK_Div1);

    /* PCLK2 = HCLK */
    RCC_PCLK2Config(RCC_HCLK_Div1);

    /* PCLK1 = HCLK/2 */
    RCC_PCLK1Config(RCC_HCLK_Div2);

    /* PLLCLK = 8MHz * 5 = 40 MHz */
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);

    /* Enable PLL */
    RCC_PLLCmd(ENABLE);

    /* Wait till PLL is ready */
    while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
    {}

    /* Select PLL as system clock source */
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

    /* Wait till PLL is used as system clock source */
    while (RCC_GetSYSCLKSource() != 0x08)
    {}
  }
  /* Enable peripheral clocks */
  RCC_AHBPeriphClockCmd (RCC_AHBPeriph_DMA1,     ENABLE);
  RCC_APB1PeriphClockCmd(
                         RCC_APB1Periph_USART2 |
                         RCC_APB1Periph_SPI2 |
                         RCC_APB1Periph_CAN,     ENABLE);
  RCC_APB2PeriphClockCmd(
                         RCC_APB2Periph_USART1 |
                         RCC_APB2Periph_GPIOA |
                         RCC_APB2Periph_GPIOB |
                         RCC_APB2Periph_GPIOC |
                         RCC_APB2Periph_GPIOD |
                         RCC_APB2Periph_GPIOE |
                         RCC_APB2Periph_AFIO |
                         RCC_APB2Periph_ADC1,    ENABLE);
}


When I debug my project, it seems to hang at the function  'while (RCC_GetSYSCLKSource() != 0x08)' . The rest of 'MUCB_configure' and 'main'is not executed.

My question is: "What cause the application to hang?"

Thank you

Last edited by MartijnK (2012-01-17 13:59:02)

Offline

 

# 2   2012-01-18 06:08:46 'RCC_GetSYSCLKSource' never becomes 0x08

atitude
Member
From: USA
Registered: 2010-12-18
Posts: 30
Website

Re: 'RCC_GetSYSCLKSource' never becomes 0x08

Beste Martijn,

I presume you are seeing what you see in simulation mode, as apposed to actual code execution? In my experience, if you want to simulate through this function, you need to build in a switch which bypasses the check your simulation hangs on. It's just that the simulation model is not 100% the same as the actual device.
Just add a define indicating you are simulating, and #ifndef the one-liner you are currently getting stuck at.

Good luck!

Offline

 

# 3   2012-01-18 11:03:34 'RCC_GetSYSCLKSource' never becomes 0x08

MartijnK
New member
Registered: 2012-01-17
Posts: 2

Re: 'RCC_GetSYSCLKSource' never becomes 0x08

In the simulation mode, the computer does't get stuck at the function mentioned before.
In the normal debug mode the function also works privided that I put breakpoints before the four following lines:

while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
    {}
   

    /* Select PLL as system clock source */
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

   
    /* Wait till PLL is used as system clock source */
    while (RCC_GetSYSCLKSource() != 0x08)
    {}
   
  }


  /* Enable peripheral clocks */
  RCC_AHBPeriphClockCmd (RCC_AHBPeriph_DMA1,     ENABLE);



But when I omit the breakpoints,  the program gets stuck again.

If I break the execution and look at the values of the 'RCC_CR' and  'RCC_CFGR' registers, I see that 'HSEON' = 'HSE oscillator on' , 'PLLON' = 'PLL ON' , 'HSERDY' =  'external 1-25 MHz oscillator ready' and 'PLLSRC' = 'HSE oscillator clock selected as PLL input clock' but 'SW' = 'HSI selected as sysyem clock' instead of 'PLL selected as system clock'.

Offline

 

Board footer