STM32F10X Çalışmalarım

Başlatan Mucit23, 12 Mart 2012, 11:17:48

Mucit23

#30
Hocam merhabalar.
Yazılımı yükledim. Çalışıyor. Şimdilik EX33Ds üzerinde deniyorum.İlk enerji verdiğimde İşlemcinin PE.2, PE.3, PE.4 ve PE.7 bitlerindeki ledler 3 defa yanıp söndü. Ardından 2,3 ve 4. bitler yürüyen ışık efekti oluşturuyor. Ayrıca PE7 de sürekli yanıp sönüyor. Şimdi farklı birşeyler deniyeyim. En azından şu GPIO işini tamamiyle çözmem gerekiyor.

Hocam bundan sonra ne yapmamı tavsiye edersiniz.

M_B

hocam iyice pin yonlendirme tanımlamalarını ogrendikten sonra Lcd ekran kullanımı hatta TFT ekran surmeye
sonrada diğer donanımları oğrenmeye çalışın derim.
İmkanın sınırlarını görmek için imkansızı denemek lazım.                                                             Fatih Sultan Mehmet

Mucit23

Arkadaşlar STM32F107 de usart kullanımı ve usart kesmesinin kullanıldığı örnek bir program gösterebilirmisiniz. Seri haberleşme ile uğraşıyorum. Seri yolla bilgisayara veri göndermeme rağmen bir türlü veri alamadım.
Yardımcı olursanız sevinirim.

Mucit23

Arkadaşlar Mehaba Daha önce hep Expkits'in boardında çalışıyordum. Şimdi aynı işlemcili başka bir boarda geçtim. Eski kodlarımı bu boardda çalıştıramadım bir türlü. İşlemcinin sistem ayarlarıyla ilgili bir problem var.
Önceki çalıştığım boardda OSC olarak 8Mhz kullanılmıştı. Yeni boardımda ise 25Mhz osc var.

İşlemcinin sistem ayarlarını buradan yapıyorum.
////////////////////////////////////////////////////////////////////////////////
//  Author   : [FERHAT YOL]											
//  Notice   : Copyright (c) 2012
//           : All Rights Reserved
//  Date     : 
//  Version  : 1.0.0
//  MCU 	 : STM32F107VC
//  Notes    : DEFAULT AYARLAMALAR
////////////////////////////////////////////////////////////////////////////////

#include "stm32f10x_lib.h"	
#include "port.h"
#include "main.h"
//#include "ks0108.h"
#include "com.h"
#include "adc.h"
#include "stdio.h"
//#include "ds18b20.h"
//#include "ds1302.h"
//#include "keypad.h"

void SystemInit(int clockMull);
void RCC_Configuration(int clockMull);
void NVIC_Configuration(void);
void setTimer1(u32 period,u32 prescaler,u32 clockdivision);
void delayMs(vu32 ms);
static vu32 TimingDelay;
/********************************SYSTEMINIT************************************/
void SystemInit(int clockMull){//clockMull clock carpani 1 veya 2 olabilir=> 2 olursa 64 mhz, 1 olursa 32 mhz de calisir
		/* System Clocks Configuration */
  	RCC_Configuration(clockMull); 
  	/* NVIC Configuration */
  	NVIC_Configuration();
  	/* SysTick clock 1ms için 4MHz (HCLK/8, default) */
  	SysTick_SetReload(4000);
  	/* SysTick Kesmesi Aktif */
	
  	SysTick_ITConfig(ENABLE);
		
}

/*******************************************************************************/
void setTimer1(u32 period,u32 prescaler,u32 clockdivision){
	
		TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
		/* TIM1 clock enable */
  	RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); 
		/* TIM1 ayarlari */
  	TIM_TimeBaseStructure.TIM_Period = period;
  	TIM_TimeBaseStructure.TIM_Prescaler = prescaler;
  	TIM_TimeBaseStructure.TIM_ClockDivision = clockdivision;
  	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  	TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
 
  	/* TIM1 güncelleme kesmesi aktif */
	   TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE);
	
			/* TIM1 sayici aktif */
			TIM_Cmd(TIM1, ENABLE);
			//GPIO_Write(GPIOB,0x00FF);
}


/*******************************************************************************/
void RCC_Configuration(int clokMull)
{
    /* RCC system reset(for debug purpose) */
    RCC_DeInit();
    /* HSE kapali */
    RCC_HSEConfig(RCC_HSE_OFF);
    /* Prefetch Buffer aktif */
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
    /* Flash ulasimi 2 clock */
    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(internal osc)/2) * 8 = 32 MHz */
    RCC_PLLConfig(RCC_PLLSource_HSI_Div2, clokMull*RCC_PLLMul_8);
    /* PLL Aktif */
    RCC_PLLCmd(ENABLE);
    /* PLL hazir olmasini bekle */
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
    /* System clock kaynagi PLL cikisi secildi */
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
    /* System clock kaynagi hazir olmasini bekle */
    while(RCC_GetSYSCLKSource() != 0x08);
}
/*******************************************************************************/

/*******************************************************************************/
void NVIC_Configuration(void)
{
	  NVIC_InitTypeDef NVIC_InitStructure;

			#ifdef  VECT_TAB_RAM
				/*  Vectör kaynagi adresi:  0x20000000 */
				NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
			#else  /* VECT_TAB_FLASH  */
				/*  Vektör kaynagi adresi:  0x08000000 */
				NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
			#endif
			 /* TIM1 güncellenme kesmesi tanitildi */
				NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQChannel;
				NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
				NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
				NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

			  NVIC_Init(&NVIC_InitStructure);
 
}


/***********************************delayMs**************************************/
void delayMs(u32 ms)
{
  /* SysTick Counter aktif */
  SysTick_CounterCmd(SysTick_Counter_Enable);
  
  TimingDelay = ms;

  while(TimingDelay != 0);

  /* SysTick Counter Pasif */
  SysTick_CounterCmd(SysTick_Counter_Disable);
  /* SysTick Counter temizlenir */
  SysTick_CounterCmd(SysTick_Counter_Clear);
}
/*******************************************************************************/

/*******************************************************************************/
void TimingDelay_Decrement(void)
{
  if (TimingDelay != 0x00)
  { 
    TimingDelay--;
  }
}
/*******************************************************************************/


Burada en çok şu konuda sıkıntı çekiyorum açıkçası. Daha önce hep piclerle uğraştığım için İşlemcinin yapısını biliyordum. Yani ne nereden ayarlanır ilgili registerler hangisi olduğu hiç bilmesem bile datasheeti 10 dk incelesem çözüyordum işi.

ARM de öyle değil.

Hepsi beni ilgilendirmemekle birlikte datasheet 1000sf. Sırf bir clock ayarlarını yapmak için 5-6 tane register ile boğuşmak gerekiyor. Tabi bunları kütüphane yapıyor ama ben kütüphaneye yapması için ne söylemem gerektiğini bilmiyorum.

Bu konuda beni bilgilendirseniz sevinirim. Sormak istediklerim OSC frekansını değiştirmek için neler yapılması gerekli? CPU hızını değiştirmek için Hangi PLL çarpanıyla oynamalıyım?


muhittin_kaplan

Mucit
çalışacağın İşlemci Hangisi ?

Mucit23

aynı işlemci hocam STM32F107VC

muhittin_kaplan

ilk etapta Datasını indirelim..

Mucit23

Ben sürekli bu işlemci ile oynadığım için datasını 3 cilt halinde bastırtmıştım. Yanımda duruyor.

muhittin_kaplan

#38
Bu DataSheet
http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00220364.pdf

buda referans man
http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/REFERENCE_MANUAL/CD00171190.pdf

refman da Figure 8. Clock tree (syf90) arat burada nereye ne yazman gerektiğini anlayacağız.

mesaj birleştirme:: 15 Kasım 2012, 18:38:25

Burada ilk kontrol edeceğimiz yer
RCC_CFGR deki Bit 17 PLLXTPRE
(RefMan sayfa 99)

Mucit23

Bu işi hakkıyla öğrenmek istiyorum.

karşıma bu çıktı verdiğiniz adreste

photo sharing
Bayağı karmaşık görünüyor.

Şimdi buradan anladığım kadarıyla OSC1 girişine max. 16Mhz kristal bağlanabilir.

Benim elimdeki boardda 25mhz takılı. Bu problem olmuyormu? Yani elimdeki boardda öyle dandik dündük birşey değil. Keil'in MCBSTM32C boardı.

Dediğiniz bite baktım sanırsam giriş frekansını 2 ye bölüp bölmeyeceğimizi ayarlıyor.
Bundan sonra adım adım gidersek  PLLSRC ve PLLMULL


muhittin_kaplan

aynen, PLLXTPRE biti girişi 2 ye bölmeyi yada doğrudan vermeyi ayarlıyor. (bu arada bu işlemciyi ben hiç kullanmadım)
sonrasında PLLSRC ile PLL ünitesinin girişi seçiliyor (HSI , HSE seçimi). PLLMUL ile çarpan ayarlanarak max 72mhz e çıkartılıyor.
Sonrasında AHB ile Bus hızları ayarlanıyor.(AHB için datasheet syf12 bakınız)
APB1 ve APB2 ye bağlı olan Pripheral lar  için buralarda bölmeler yapılıyor.

Mucit23

Anladım dediklerinizi

25Mhz konusuna takıldım birtek. Acaba internal OSC yi mi aktif edeyim.

Şimdi bu dediklerinizi uygulamaya gelince biraz durmam gerekiyor. Kütüphanenin nasıl kullanılacağını iyice öğrenmem gerekiyor.

Bu tür ayarlar burda yapılıyor

    /* RCC system reset(for debug purpose) */
    RCC_DeInit();
    /* HSE kapali */
    RCC_HSEConfig(RCC_HSE_OFF);
    /* Prefetch Buffer aktif */
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
    /* Flash ulasimi 2 clock */
    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(internal osc)/2) * 8 = 32 MHz */
    RCC_PLLConfig(RCC_PLLSource_HSI_Div2, clokMull*RCC_PLLMul_8);
    /* PLL Aktif */
    RCC_PLLCmd(ENABLE);
    /* PLL hazir olmasini bekle */
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
    /* System clock kaynagi PLL cikisi secildi */
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
    /* System clock kaynagi hazir olmasini bekle */
    while(RCC_GetSYSCLKSource() != 0x08);


Burada biraz sıkıntı çekiyorum.

mesaj birleştirme:: 15 Kasım 2012, 19:19:39

Bi sn;

HSE kapalı olarak ayarlanmış Bu durumda internal OSC aktif olmazmı?

muhittin_kaplan

#42
evet

mesaj birleştirme:: 15 Kasım 2012, 19:30:43

CooCox örneği..
/**
  ***************************************************************************** 
  * @title   RCC_Exp.c
  * @author  CooCox
  * @date    31 Oct 2012
  * @brief   This example shows how to configure the System clock(SYSCLK) to 
  *          have different
  *          frequencies: 24MHz, 36MHz, 48MHz, 56MHz and 72MH
  *          z (common frequencies that covers
  *          the major of the applications
  *          ).
  *******************************************************************************
  */
////// The above comment is automatically generated by CoIDE ///////////////////

#include "stm32f10x.h"
#include "stm32f10x_flash.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"
#include "misc.h"

/* Uncomment the line corresponding to the desired System clock (SYSCLK)
 frequency (after reset the HSI is used as SYSCLK source) */
//#define SYSCLK_HSE
#define SYSCLK_FREQ_24MHz
#define LED_PORT GPIOB
//#define SYSCLK_FREQ_36MHz
//#define SYSCLK_FREQ_48MHz
//#define SYSCLK_FREQ_56MHz
//#define SYSCLK_FREQ_72MHz
#define DELAY_COUNT    0x3FFFF

/***************************************************************************//**
 * Global variables
 ******************************************************************************/
GPIO_InitTypeDef GPIO_InitStructure;
RCC_ClocksTypeDef RCC_ClockFreq;
ErrorStatus HSEStartUpStatus;

/***************************************************************************//**
 * Declare function prototype
 ******************************************************************************/
void NVIC_Configuration(void);
void Delay(__IO uint32_t nCount);
void SetSysClock(void);
#ifdef SYSCLK_HSE
void SetSysClockToHSE(void);
#elif defined SYSCLK_FREQ_24MHz
void SetSysClockTo24(void);
#elif defined SYSCLK_FREQ_36MHz
void SetSysClockTo36(void);
#elif defined SYSCLK_FREQ_48MHz
void SetSysClockTo48(void);
#elif defined SYSCLK_FREQ_56MHz
void SetSysClockTo56(void);
#elif defined SYSCLK_FREQ_72MHz
void SetSysClockTo72(void);
#endif

/***************************************************************************//**
 * @brief  RCC example.This example shows how to configure the System clock(SYSCLK) 
 *            to have different frequencies: 24MHz, 36MHz, 48MHz, 56MHz and 72MHz.
 *            You will see the LED PB8 PB9 PB10 blink successively.
 ******************************************************************************/
void RCC_Exp(void)
{
    /* Configure the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers */
    SetSysClock();

    /* This function fills the RCC_ClockFreq structure with the current
     frequencies of different on chip clocks (for debug purpose) */
    RCC_GetClocksFreq(&RCC_ClockFreq);

    /* Enable Clock Security System(CSS): this will generate an NMI exception
     when HSE clock fails */
    RCC_ClockSecuritySystemCmd( ENABLE);

    /* NVIC configuration ------------------------------------------------------*/
    NVIC_Configuration();

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
    GPIO_Init(GPIOB, &GPIO_InitStructure);

    /* Output HSE clock on MCO pin ---------------------------------------------*/
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOA, &GPIO_InitStructure);
    RCC_MCOConfig( RCC_MCO_HSE);

    while (1) 
    {
        /* Blink LED PB8 */
        GPIO_WriteBit(LED_PORT, GPIO_Pin_8, Bit_SET);
        /* Insert delay */
        Delay(DELAY_COUNT);
        GPIO_WriteBit(LED_PORT, GPIO_Pin_8, Bit_RESET);
        Delay(DELAY_COUNT);

        /* Blink LED PB9 */
        GPIO_WriteBit(LED_PORT, GPIO_Pin_9, Bit_SET);
        /* Insert delay */
        Delay(DELAY_COUNT);
        GPIO_WriteBit(LED_PORT, GPIO_Pin_9, Bit_RESET);
        Delay(DELAY_COUNT);

        /* Blink LED PB10 */
        GPIO_WriteBit(LED_PORT, GPIO_Pin_10, Bit_SET);
        /* Insert delay */
        Delay(DELAY_COUNT);
        GPIO_WriteBit(LED_PORT, GPIO_Pin_10, Bit_RESET);
        Delay(DELAY_COUNT);
    }
}

/***************************************************************************//**
 * @brief  Configures the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers.
 ******************************************************************************/
void SetSysClock(void) {
    /* The System clock configuration functions defined below assume that:
     - For Low, Medium and High density devices an external 8MHz crystal is
     used to drive the System clock.
     - For Connectivity line devices an external 25MHz crystal is used to drive
     the System clock.
     If you are using different crystal you have to adapt those functions accordingly.*/

#if defined SYSCLK_HSE
    SetSysClockToHSE();
#elif defined SYSCLK_FREQ_24MHz
    SetSysClockTo24();
#elif defined SYSCLK_FREQ_36MHz
    SetSysClockTo36();
#elif defined SYSCLK_FREQ_48MHz
    SetSysClockTo48();
#elif defined SYSCLK_FREQ_56MHz
    SetSysClockTo56();
#elif defined SYSCLK_FREQ_72MHz
    SetSysClockTo72();
#endif

    /* If none of the define above is enabled, the HSI is used as System clock
     source (default after reset) */
}

/***************************************************************************//**
 * @brief  Selects HSE as System clock source and configure HCLK, PCLK2 and PCLK1 prescalers.
 ******************************************************************************/
void SetSysClockToHSE(void) 
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* 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 0 wait state */
        FLASH_SetLatency( FLASH_Latency_0);

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

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

        /* PCLK1 = HCLK */
        RCC_PCLK1Config(RCC_HCLK_Div1);

        /* Select HSE as system clock source */
        RCC_SYSCLKConfig( RCC_SYSCLKSource_HSE);

        /* Wait till PLL is used as system clock source */
        while (RCC_GetSYSCLKSource() != 0x04) 
        {
        }
    } 
    else 
    { /* If HSE fails to start-up, the application will have wrong clock configuration.
     User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1) 
        {
        }
    }
}

/***************************************************************************//**
 * @brief  Sets System clock frequency to 24MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
 ******************************************************************************/
void SetSysClockTo24(void) 
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* 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 0 wait state */
        FLASH_SetLatency( FLASH_Latency_0);

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

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

        /* PCLK1 = HCLK */
        RCC_PCLK1Config(RCC_HCLK_Div1);

        /* PLLCLK = 8MHz * 3 = 24 MHz */
        RCC_PLLConfig(0x00010000, 0x00040000);

        /* 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) 
        {
        }
    } 
    else 
    { /* If HSE fails to start-up, the application will have wrong clock configuration.
     User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1) 
        {
        }
    }
}

/***************************************************************************//**
 * @brief  Sets System clock frequency to 36MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
 ******************************************************************************/
void SetSysClockTo36(void) 
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* 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 1 wait state */
        FLASH_SetLatency( FLASH_Latency_1);

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

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

        /* PCLK1 = HCLK */
        RCC_PCLK1Config(RCC_HCLK_Div1);

        /* PLLCLK = (8MHz / 2) * 9 = 36 MHz */
        RCC_PLLConfig(0x00030000, 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) 
        {
        }
    } 
    else 
    { /* If HSE fails to start-up, the application will have wrong clock configuration.
     User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1) 
        {
        }
    }
}

/***************************************************************************//**
 * @brief  Sets System clock frequency to 48MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
 ******************************************************************************/
void SetSysClockTo48(void) 
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* 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 1 wait state */
        FLASH_SetLatency( FLASH_Latency_1);

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

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

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

        /* PLLCLK = 8MHz * 6 = 48 MHz */
        RCC_PLLConfig(0x00010000, RCC_PLLMul_6);

        /* 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) 
        {
        }
    }
    else 
    { /* If HSE fails to start-up, the application will have wrong clock configuration.
     User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1)
        {
        }
    }
}

/***************************************************************************//**
 * @brief  Sets System clock frequency to 56MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
 ******************************************************************************/
void SetSysClockTo56(void) 
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* 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 * 7 = 56 MHz */
        RCC_PLLConfig(0x00010000, RCC_PLLMul_7);

        /* 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) 
        {
        }
    } 
    else 
    { /* If HSE fails to start-up, the application will have wrong clock configuration.
     User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1) 
        {
        }
    }
}

/***************************************************************************//**
 * @brief  Sets System clock frequency to 72MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
 ******************************************************************************/
void SetSysClockTo72(void)
{
    /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
    /* 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 * 9 = 72 MHz */
        RCC_PLLConfig(0x00010000, 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) 
        {
        }
    } 
    else 
    { /* If HSE fails to start-up, the application will have wrong clock configuration.
     User can add here some code to deal with this error */

        /* Go to infinite loop */
        while (1) 
        {
        }
    }
}

/***************************************************************************//**
 * @brief  Configures Vector Table base location.
 ******************************************************************************/
void NVIC_Configuration(void) 
{
    NVIC_InitTypeDef NVIC_InitStructure;

    /* Enable and configure RCC global IRQ channel */
    NVIC_InitStructure.NVIC_IRQChannel = RCC_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
}

/**
 * @brief  Inserts a delay time.
 * @param  nCount: specifies the delay time length.
 * @retval None
 */
void Delay(__IO uint32_t nCount)
{
    for(; nCount!= 0;nCount--);
}

/***************************************************************************//**
 * @brief  This function handles RCC interrupt request.
 ******************************************************************************/
void RCC_IRQHandler(void) 
{
    if (RCC_GetITStatus(RCC_IT_HSERDY) != RESET) 
    {
        /* Clear HSERDY interrupt pending bit */
        RCC_ClearITPendingBit( RCC_IT_HSERDY);

        /* Check if the HSE clock is still available */
        if (RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET) 
        {
            /* Enable PLL: once the PLL is ready the PLLRDY interrupt is generated */
            RCC_PLLCmd( ENABLE);
        }
    }

    if (RCC_GetITStatus(RCC_IT_PLLRDY) != RESET) 
    {
        /* Clear PLLRDY interrupt pending bit */
        RCC_ClearITPendingBit( RCC_IT_PLLRDY);

        /* Check if the PLL is still locked */
        if (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) != RESET) 
        {
            /* Select PLL as system clock source */
            RCC_SYSCLKConfig( RCC_SYSCLKSource_PLLCLK);
        }
    }
}

/***************************************************************************//**
 * @brief  This function handles NMI exception.
 ******************************************************************************/
void NMI_Handler(void) 
{
    /* This interrupt is generated when HSE clock fails */

    if (RCC_GetITStatus(RCC_IT_CSS) != RESET)
    {
    	/* At this stage: HSE, PLL are disabled (but no change on PLL config) and HSI
        is selected as system clock source */

        /* Enable HSE */
        RCC_HSEConfig( RCC_HSE_ON);

        /* Enable HSE Ready interrupt */
        RCC_ITConfig(RCC_IT_HSERDY, ENABLE);

        /* Enable PLL Ready interrupt */
        RCC_ITConfig(RCC_IT_PLLRDY, ENABLE);

        /* Clear Clock Security System interrupt pending bit */
        RCC_ClearITPendingBit( RCC_IT_CSS);

        /* Once HSE clock recover, the HSERDY interrupt is generated and in the RCC ISR
         routine the system clock will be reconfigured to its previous state (before
         HSE clock failure) */
    }
}

Mucit23

Şuan kart yanımda değil yarın tekrar deneyeceğim. 
CooCox ile Keil arasında kullanım açısından fark varmı? Kod yapısı aynı herhalde, Neden CooCox kullanıyorsunuz

muhittin_kaplan

Kod tamamlama var. tek sebebim bu. Eklediğim kütüphane içerisindeki fonksiyonları kod  yazarken görebiliyorsun. Unutmadan Bedava
Eclipse Tabanlı bir derleyici.
Code Red e de bakacağım.