Picproje Elektronik Sitesi

MİKRODENETLEYİCİLER => ARM => ARM7 Mikrodenetleyici => Konuyu başlatan: yldzelektronik - 16 Haziran 2014, 15:07:21

Başlık: Stm32f10x
Gönderen: yldzelektronik - 16 Haziran 2014, 15:07:21
Merabalar,

Stm32f103 için STM32F10x_StdPeriph_Lib_V3.5.0 indirdim.

İçerisindeki örnek programları inceliyordum.Ancak kafama takılan bazı kısımlar var.

Main içinde hiçbir yerde system init veya RCC_Configuration gibi bir çağrı yok.

Mcunun çalışma frekansını define ile system_stm32f10x.c dosyasında yapılmış.

Ancak main içinde hiç bir yerde bir çağrı yok.

Şimdi birşey fark ettim.Startup dosyasında;

IMPORT  SystemInit şeklinde bir bildirim var.Bu ne demek?Bütün hali şöyle;

               
; Reset handler
Reset_Handler   PROC
                EXPORT  Reset_Handler             [WEAK]
                IMPORT  __main
                IMPORT  SystemInit
                LDR     R0, =SystemInit
                BLX     R0               
                LDR     R0, =__main
                BX      R0
                ENDP


Acaba keil derlerken kendisi mi hallediyor?Nasıl oluyor da mcunun osc init kısmı falan halediliyor?
Başlık: Ynt: Stm32f10x
Gönderen: fgokcegoz - 16 Haziran 2014, 15:12:02
Yazılım main e düşmeden önce startup kısmına düşüyor. Bu aşamada system init fonksiyonu çağrılıyor. RCC Konfigürasyonu burada hallediliyor. Ondan sonra kod, main e düşüyor... Ve senin yazdığın kod dan devam ediyor...
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 16 Haziran 2014, 17:06:51
Anladım.Teşekkürler.

Peki mcu ayaklandırmak için izlememiz gereken yol nedir?

Basit bir buton kontrolünü ele alalım.Butona basıp ledi yakalım.

İlk önce system init ile mcunun clock ayarlarını yapıyoruz.

Daha sonra gpio init etmemiz gerekicek.Bunun için en başta hangi bus üzerinde ise onun clockunu aktif etmemiz gerekicek;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOx, ENABLE); gibi.

Daha sonra GPIO_InitTypeDef yapısını kullanarak GPIO ları port port init edeceğiz.

Buraya kadar doğru mudur?
Başlık: Ynt: Stm32f10x
Gönderen: Mucit23 - 16 Haziran 2014, 17:13:13
Evet Doğrudur,
GPIO'yu init ettikten sonra GPIO kütüphanesindeki fonksiyonları kullanarak işlemlerini yapabilirsin
Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 16 Haziran 2014, 17:16:33
Alıntı Yap
void GPIO_Configuration(void)
{

/*
* GPIOC12 giriş olarak GPIOD.2 çıkış olarak ayarlanıyor
*/
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
    GPIO_Init(GPIOC, &GPIO_InitStructure);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
}

Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 16 Haziran 2014, 17:24:35
Anladım.

Ancak kafamı karıştıran bir nokta var.Input için 4 mod var.

Floating,Pull Up, Pull Down. Bunlar tamam. GPIO_Mode_AIN dediği nedir?

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; ile pin pull up oldu, doğru mu?

Peki ben dışarıda pini pull up yaptım.GPIO init ederken de pull up olarak belirtmek durumundayım sanırım?Floating yapsam ne olur?
Başlık: Ynt: Stm32f10x
Gönderen: fgokcegoz - 16 Haziran 2014, 17:29:53
Floating, Pull-Up, Pull-Down modları işlemciye göredir. Yani dışarıdan pull-up veya pull-down yapacaksanız floating olarak ayarlayabilirsiniz. Pull-Up veya Pull-Down moduna alacaksanız, dahili olarak zayıf pull (up/down) yapılmış olur. İlgili pini analog input olarak kullanacaksanız da, GPIO_Mode_AIN olarak ayarlayacaksınız.
Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 16 Haziran 2014, 17:30:05
1.Analog Input
IPU, Input Pull UP
Hayır değilsin, Eğer Dışardan PullUp Yaparsan Programda Float Yapabilirsin.
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 17 Haziran 2014, 16:16:54
Alternate function ile bir donanımı kullanmak istersek süreç nasıl olacak?

Örneğin tft için fsmc ihtiyacım var.Bunun için pin yapılandırması nasıl yapılmalı?
Başlık: Ynt: Stm32f10x
Gönderen: kimlenbu - 17 Haziran 2014, 16:21:41
fsmc ayarları için forumda ssd1963 için verilmiş kodlar var, oradan feyz alabilirsin. Ben olsam ilgili lcd için direkt hazır proje arardım , fsmc yapılandırmasından yazma, çizme fonksiyonlarına kadar hazır geliyor.
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 17 Haziran 2014, 16:51:52
Buldum aslında fakat indiremiyorum.Dosya.tc falan iş yerinde blocklu.

Rica etsem bir yere upload eder misiniz?Veya code tag ile buraya koysanız?
Başlık: Ynt: Stm32f10x
Gönderen: Müh. müh. - 17 Haziran 2014, 21:13:37
yldzelektronik

Bende şuan st peripheral lib i öğrenmeye çalışıyorum.

Tavsiye edeceğim yöntem şu, öncelikle chip in reference manual ini okuyun. Orada register seviyesinde anlatım mevcut. Led yakıp söndürmek için adım adım neler yapılacağını anlıyorsunuz. Sonrasında, ST lib te, RCC->AHB1ENR gibi direk register a erişmiyorsunuz, RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); böyle basitçe erişim sağlıyorsunuz.


Şuan librarlerin içersini açıp, tek tek analamaya çalışıyorum. Sanırım st liblerin help dosyaları gibi birşey yok? Nette mcu nun her birimi için yapılmış önekler varmıdır? (mesela uart, spi, i2c, fsmc vs..)
Başlık: Ynt: Stm32f10x
Gönderen: X-Fi - 17 Haziran 2014, 21:20:58
Alıntı yapılan: Müh. müh. - 17 Haziran 2014, 21:13:37
....RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); ....

Hocam yukarıdaki yazım STM32F10x için yanlış doğrusu şu olacak; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);


Aşağıdaki sayfanın design resource kısmında stdlibrary ile yapılmış yazılımlar mevcut öğrenmenizde yardımcı olur.

http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1031/LN1565/PF206936 (http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1031/LN1565/PF206936)
Başlık: Ynt: Stm32f10x
Gönderen: Müh. müh. - 17 Haziran 2014, 21:29:59
Alıntı yapılan: X-Fi - 17 Haziran 2014, 21:20:58
Hocam yukarıdaki yazım STM32F10x için yanlış doğrusu şu olacak; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);


Aşağıdaki sayfanın design resource kısmında stdlibrary ile yapılmış yazılımlar mevcut öğrenmenizde yardımcı olur.

http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1031/LN1565/PF206936 (http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1031/LN1565/PF206936)

Yukarıda anlattığım bilgileri stm32f407 yi baz alarak verdim. Elimin altında reference manuel i ve st lib. i olduğundan oldu. Mesajım zaten, nasıl yapacağımızı anlatmayı amaçlıyordu.

Evet örnekler varmış. İnceleyip, öğrenmek gerekli. Yalnız mcu içersinde 15-20 kadar birim var. Düzgün bir help dosyası ve içersine çok basit kod satırları ile, hiç birşey bilmeden bile 15 dk da yazılım yazılabilirdi..
Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 17 Haziran 2014, 21:55:13
Hocam 103 ile 100 un lib ayni. Bu acidan yukarda kensi blogumu ornek gosterdim. Ayni yazilar forumda da var ama bulmasi uzun suruyor. Eger lib kullanarak debug yaparsaniz yine gorecek oldugunuz Tim2->cnt gibi register erisimidir.
Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 18 Haziran 2014, 01:10:56
buldum.

bunu ben print edip kitap heline getirdim.
http://www6.in.tum.de/pub/Main/TeachingWs2012Echtzeitsysteme/stm32f_firmw.pdf (http://www6.in.tum.de/pub/Main/TeachingWs2012Echtzeitsysteme/stm32f_firmw.pdf)
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 18 Haziran 2014, 07:58:41
GPIO ları anladım gibi.Önce bağlı olduğu bus için clock erişimini sağlıyoruz sonra mod ile giriş çıkış durumlarını belirleyip erişim sağlıyoruz.Tek seferde erişimin olması ne güzel.Gerçi tam bilmiyorum ama picdeki gibi mi acaba?Önce bank bişeye geç sonra pini yönlendir.Sonra yine önceki banka geç falan gibi?

Benim anlamakta sıkıntı yaşadığım kısım alternate function kısımı.Bir pin hem gpio, hem fsmc d0 hem sdio d2 (farazi örnek.Böyle olmasa da bazı pinlerde 3 tane remap ile erişilebilecek donanımlar var).Bunları nasıl hallediyoruz.Sanırım şöyle;

Önce gpio gibi düşünüp portu hangi busu bağlıysa clocklandırıyoruz.Sonra alternate function olduğunu belirtiyoruz.Sonra da hangi donanım ise (yukarıdaki örnek için fmsc) onun enable mi ediyoruz clock mu veriyoruz?Nasıl yapılıyor?Burada işte kafam karışıyor biraz.

Bir de bu pinin 3. durumu var (yine yukarıdaki örnek için fsmc değil sdio olması).
Başlık: Ynt: Stm32f10x
Gönderen: MC_Skywalker - 18 Haziran 2014, 08:03:54
mcu üreticisine göre işlem biraz değişiyor ama dediğin gibi;
clock uygula portu aktif et, pinin durumunu belirle
Pin doğrudan ram da bir bölge okur yazar gibi adresine erişip işlem yapabilirsin.

Ek:
örn

void PortF_Init(void)                   //TivaC nin port F ilk kurulumu (initializing)
{
  volatile unsigned long delay;
        SYSCTL_RCGC2_R |= 0x00000020; // 1) Port F'in clock aktif et
delay = SYSCTL_RCGC2_R; // clock için bir müddeet bekle
GPIO_PORTF_LOCK_R = 0x4C4F434B; // 2) Port F'in GPIO aç
GPIO_PORTF_CR_R = 0x1F; //  PF4-0 ilk 5 bit te değişikliğe izinver
                                        //
GPIO_PORTF_AMSEL_R = 0x00; // 3) Port F Analog özelliği kullanılmayacak
GPIO_PORTF_PCTL_R = 0x00000000; // 4) PCTL GPIO on PF4-0
GPIO_PORTF_DIR_R = 0x0E; // 5) PF4,PF0 girş, PF3-1 çıkış
GPIO_PORTF_AFSEL_R = 0x00; // 6) PF7-0 portun alternatif fonksiyonlarını kapat
GPIO_PORTF_PUR_R = 0x11; // PF0 ve PF4 için zayıf iç pull-up devreye al
GPIO_PORTF_DEN_R = 0x1F; // 7) PF4-0 Dijital girşi çıkış aktif et.
// GPIO_PORTF_DATA_R = 0x00;       // Port F kaydedicisine 0x00 değeri init işleminden sonra yükle
}
Başlık: Ynt: Stm32f10x
Gönderen: AsHeS - 18 Haziran 2014, 09:05:34
Kütüphaneden ezberlemeye çalışacağınıza datasheetten bakıp yazmak çok daha hızlı ve de init prosedürleri adım adım anlatılıyor genelde. Bana kullanması daha kolay geliyor açıkçası kütüphanede neyi hangi sırada yapacaksınız meçhul. Zaten buna sarf edeceğim eforu datasheetin yapılanmasını anlamaya ayırmakla çok mantıklı bir iş yaptığımı da ekstra olarak düşünmekteyim. Ha hiç mi geçmeyi düşünmüyorum kütüphanelere evet geçicem fakat kolay olduğu için değil alt katmanda düzeni sağlamak için.
Başlık: Ynt: Stm32f10x
Gönderen: CoşkuN - 18 Haziran 2014, 09:08:27
"Karşıt görüşlü "kütüphaneciler" ve "registercılar" grupları arasında çıkan kavgada 3 kişi yaralandı" haberleri görür müyüz  :P

Register'ları anlamak bence de çok faydalı başlangıçta, ama bir süre sonra işkenceye de dönebiliyor. Kütüphaneler de zaten rahatlığı sağlamak için var. Ezberleme diye birşey zaten geçerli değil. Bu işler ezber kabul etmiyor pek.
Başlık: Ynt: Stm32f10x
Gönderen: AsHeS - 18 Haziran 2014, 09:12:39
Alıntı yapılan: CoşkuN - 18 Haziran 2014, 09:08:27
"Karşıt görüşlü "kütüphaneciler" ve "registercılar" grupları arasında çıkan kavgada 3 kişi yaralandı" haberleri görür müyüz  :P


Hocam yukarıda da dediğim gibi kütüphane bana açıkçası zul geliyor ama kodda standartlaşmak için kullanılması iyi olur.
Başlık: Ynt: Stm32f10x
Gönderen: Gökhan BEKEN - 18 Haziran 2014, 10:22:04
Ben de bunları buldum:

(yukarıdakinin aynısı)STM32F101xx and STM32F103xx:
https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Attachments/25258/UM0427%20USER%20MANUAL.pdf (https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Attachments/25258/UM0427%20USER%20MANUAL.pdf)

STM32F2xx Standard Peripheral Library:
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00023896.pdf (http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00023896.pdf)
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 24 Haziran 2014, 10:29:22
Merabalar,

Bu system_init olayı çok kafa karıştırıcı bir hal aldı.Normal şartlarda ben systeminit tanımlamadığımda startup dosyasında gösterilen yere gitmesi gerek miyor mı?Veya ben startup dosyasında gösterilen yere gitmesini nasıl önleyebilirim?Nasıl kendi osc rutinlerimi hazırlayabilirim?
Başlık: Ynt: Stm32f10x
Gönderen: Mucit23 - 24 Haziran 2014, 10:43:42
Normalde Reset vektöründen sonra program ilk olarak system init fonksiyonunu işler sonrasında main'e düşer.
Sende main içerisinde system init fonksiyonunu çağırabilirsin.
Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 24 Haziran 2014, 13:57:25
Hocam mobilden yaziyorum, benim blogda f10x ile alakali yazilarda kendi clock ayarlarim mevcut alla system init fonksiyonuna ihtiyaciniz yok
Başlık: Ynt: Stm32f40x
Gönderen: yldzelektronik - 24 Haziran 2014, 14:50:55
Başlık stm32f10x ancak stm32f407 ile uğraşıyorum.

Clock config tool exceli ile clock ayarlarını yapıp external seçmeme rağmen hep internal seçiyo ve bir türlü 168mhz de koşturamadım.Bülent abinin systeminit fonksiyonu ile yapabiliyorum ancak.O toolun system initi şöyle;

/**
  ******************************************************************************
  * @file    system_stm32f4xx.c
  * @author  MCD Application Team
  * @version V1.0.1
  * @date    24-June-2014
  * @brief   CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
  *          This file contains the system clock configuration for STM32F4xx devices,
  *          and is generated by the clock configuration tool
  *          stm32f4xx_Clock_Configuration_V1.0.1.xls
  *             
  * 1.  This file provides two functions and one global variable to be called from
  *     user application:
  *      - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
  *                      and Divider factors, AHB/APBx prescalers and Flash settings),
  *                      depending on the configuration made in the clock xls tool.
  *                      This function is called at startup just after reset and
  *                      before branch to main program. This call is made inside
  *                      the "startup_stm32f4xx.s" file.
  *
  *      - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
  *                                  by the user application to setup the SysTick
  *                                  timer or configure other parameters.
  *                                     
  *      - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
  *                                 be called whenever the core clock is changed
  *                                 during program execution.
  *
  * 2. After each device reset the HSI (16 MHz) is used as system clock source.
  *    Then SystemInit() function is called, in "startup_stm32f4xx.s" file, to
  *    configure the system clock before to branch to main program.
  *
  * 3. If the system clock source selected by user fails to startup, the SystemInit()
  *    function will do nothing and HSI still used as system clock source. User can
  *    add some code to deal with this issue inside the SetSysClock() function.
  *
  * 4. The default value of HSE crystal is set to 25MHz, refer to "HSE_VALUE" define
  *    in "stm32f4xx.h" file. When HSE is used as system clock source, directly or
  *    through PLL, and you are using different crystal you have to adapt the HSE
  *    value to your own configuration.
  *
  * 5. This file configures the system clock as follows:
  *=============================================================================
  *=============================================================================
  *        Supported STM32F4xx device revision    | Rev A
  *-----------------------------------------------------------------------------
  *        System Clock source                    | PLL (HSE)
  *-----------------------------------------------------------------------------
  *        SYSCLK(Hz)                             | 168000000
  *-----------------------------------------------------------------------------
  *        HCLK(Hz)                               | 168000000
  *-----------------------------------------------------------------------------
  *        AHB Prescaler                          | 1
  *-----------------------------------------------------------------------------
  *        APB1 Prescaler                         | 4
  *-----------------------------------------------------------------------------
  *        APB2 Prescaler                         | 2
  *-----------------------------------------------------------------------------
  *        HSE Frequency(Hz)                      | 8000000
  *-----------------------------------------------------------------------------
  *        PLL_M                                  | 8
  *-----------------------------------------------------------------------------
  *        PLL_N                                  | 336
  *-----------------------------------------------------------------------------
  *        PLL_P                                  | 2
  *-----------------------------------------------------------------------------
  *        PLL_Q                                  | 7
  *-----------------------------------------------------------------------------
  *        PLLI2S_N                               | NA
  *-----------------------------------------------------------------------------
  *        PLLI2S_R                               | NA
  *-----------------------------------------------------------------------------
  *        I2S input clock                        | NA
  *-----------------------------------------------------------------------------
  *        VDD(V)                                 | 3,3
  *-----------------------------------------------------------------------------
  *        Main regulator output voltage          | Scale1 mode
  *-----------------------------------------------------------------------------
  *        Flash Latency(WS)                      | 5
  *-----------------------------------------------------------------------------
  *        Prefetch Buffer                        | OFF
  *-----------------------------------------------------------------------------
  *        Instruction cache                      | ON
  *-----------------------------------------------------------------------------
  *        Data cache                             | ON
  *-----------------------------------------------------------------------------
  *=============================================================================
  ******************************************************************************
  * @attention
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  ******************************************************************************
  */

/** @addtogroup CMSIS
  * @{
  */

/** @addtogroup stm32f4xx_system
  * @{
  */ 
 
/** @addtogroup STM32F4xx_System_Private_Includes
  * @{
  */

#include "stm32f4xx.h"

/**
  * @}
  */

/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
  * @{
  */

/**
  * @}
  */

/** @addtogroup STM32F4xx_System_Private_Defines
  * @{
  */

/************************* Miscellaneous Configuration ************************/
/*!< Uncomment the following line if you need to use external SRAM mounted
     on STM324xG_EVAL board as data memory  */
/* #define DATA_IN_ExtSRAM */

/*!< Uncomment the following line if you need to relocate your vector Table in
     Internal SRAM. */
/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET  0x00 /*!< Vector Table base offset field.
                                   This value must be a multiple of 0x200. */
/******************************************************************************/

/************************* PLL Parameters *************************************/
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */
#define PLL_M      8
#define PLL_N      336

/* SYSCLK = PLL_VCO / PLL_P */
#define PLL_P      2

/* USB OTG FS, SDIO and RNG Clock =  PLL_VCO / PLLQ */
#define PLL_Q      7

/******************************************************************************/

/**
  * @}
  */

/** @addtogroup STM32F4xx_System_Private_Macros
  * @{
  */

/**
  * @}
  */

/** @addtogroup STM32F4xx_System_Private_Variables
  * @{
  */

  uint32_t SystemCoreClock = 168000000;

  __I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};

/**
  * @}
  */

/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
  * @{
  */

static void SetSysClock(void);
#ifdef DATA_IN_ExtSRAM
  static void SystemInit_ExtMemCtl(void);
#endif /* DATA_IN_ExtSRAM */

/**
  * @}
  */

/** @addtogroup STM32F4xx_System_Private_Functions
  * @{
  */

/**
  * @brief  Setup the microcontroller system
  *         Initialize the Embedded Flash Interface, the PLL and update the
  *         SystemFrequency variable.
  * @param  None
  * @retval None
  */
void SystemInit(void)
{
  /* FPU settings ------------------------------------------------------------*/
  #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
    SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */
  #endif
  /* Reset the RCC clock configuration to the default reset state ------------*/
  /* Set HSION bit */
  RCC->CR |= (uint32_t)0x00000001;

  /* Reset CFGR register */
  RCC->CFGR = 0x00000000;

  /* Reset HSEON, CSSON and PLLON bits */
  RCC->CR &= (uint32_t)0xFEF6FFFF;

  /* Reset PLLCFGR register */
  RCC->PLLCFGR = 0x24003010;

  /* Reset HSEBYP bit */
  RCC->CR &= (uint32_t)0xFFFBFFFF;

  /* Disable all interrupts */
  RCC->CIR = 0x00000000;

#ifdef DATA_IN_ExtSRAM
  SystemInit_ExtMemCtl();
#endif /* DATA_IN_ExtSRAM */
         
  /* Configure the System clock source, PLL Multiplier and Divider factors,
     AHB/APBx prescalers and Flash settings ----------------------------------*/
  SetSysClock();

  /* Configure the Vector Table location add offset address ------------------*/
#ifdef VECT_TAB_SRAM
  SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
  SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif
}

/**
   * @brief  Update SystemCoreClock variable according to Clock Register Values.
  *         The SystemCoreClock variable contains the core clock (HCLK), it can
  *         be used by the user application to setup the SysTick timer or configure
  *         other parameters.
  *           
  * @note   Each time the core clock (HCLK) changes, this function must be called
  *         to update SystemCoreClock variable value. Otherwise, any configuration
  *         based on this variable will be incorrect.         
  *     
  * @note   - The system frequency computed by this function is not the real
  *           frequency in the chip. It is calculated based on the predefined
  *           constant and the selected clock source:
  *             
  *           - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
  *                                             
  *           - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
  *                         
  *           - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
  *             or HSI_VALUE(*) multiplied/divided by the PLL factors.
  *         
  *         (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value
  *             16 MHz) but the real value may vary depending on the variations
  *             in voltage and temperature.   
  *   
  *         (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value
  *              25 MHz), user has to ensure that HSE_VALUE is same as the real
  *              frequency of the crystal used. Otherwise, this function may
  *              have wrong result.
  *               
  *         - The result of this function could be not correct when using fractional
  *           value for HSE crystal.
  *     
  * @param  None
  * @retval None
  */
void SystemCoreClockUpdate(void)
{
  uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
 
  /* Get SYSCLK source -------------------------------------------------------*/
  tmp = RCC->CFGR & RCC_CFGR_SWS;

  switch (tmp)
  {
    case 0x00:  /* HSI used as system clock source */
      SystemCoreClock = HSI_VALUE;
      break;
    case 0x04:  /* HSE used as system clock source */
      SystemCoreClock = HSE_VALUE;
      break;
    case 0x08:  /* PLL used as system clock source */

      /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
         SYSCLK = PLL_VCO / PLL_P
         */   
      pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
      pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
     
      if (pllsource != 0)
      {
        /* HSE used as PLL clock source */
        pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
      }
      else
      {
        /* HSI used as PLL clock source */
        pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);     
      }

      pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
      SystemCoreClock = pllvco/pllp;
      break;
    default:
      SystemCoreClock = HSI_VALUE;
      break;
  }
  /* Compute HCLK frequency --------------------------------------------------*/
  /* Get HCLK prescaler */
  tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
  /* HCLK frequency */
  SystemCoreClock >>= tmp;
}

/**
  * @brief  Configures the System clock source, PLL Multiplier and Divider factors,
  *         AHB/APBx prescalers and Flash settings
  * @Note   This function should be called only once the RCC clock configuration 
  *         is reset to the default reset state (done in SystemInit() function).   
  * @param  None
  * @retval None
  */
static void SetSysClock(void)
{
/******************************************************************************/
/*            PLL (clocked by HSE) used as System clock source                */
/******************************************************************************/
  __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
 
  /* Enable HSE */
  RCC->CR |= ((uint32_t)RCC_CR_HSEON);

  /* Wait till HSE is ready and if Time out is reached exit */
  do
  {
    HSEStatus = RCC->CR & RCC_CR_HSERDY;
    StartUpCounter++;
  } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));

  if ((RCC->CR & RCC_CR_HSERDY) != RESET)
  {
    HSEStatus = (uint32_t)0x01;
  }
  else
  {
    HSEStatus = (uint32_t)0x00;
  }

  if (HSEStatus == (uint32_t)0x01)
  {
    /* Select regulator voltage output Scale 1 mode, System frequency up to 168 MHz */
    RCC->APB1ENR |= RCC_APB1ENR_PWREN;
    PWR->CR |= PWR_CR_VOS;

    /* HCLK = SYSCLK / 1*/
    RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
     
    /* PCLK2 = HCLK / 2*/
    RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
   
    /* PCLK1 = HCLK / 4*/
    RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;

    /* Configure the main PLL */
    RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) |
                   (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24);

    /* Enable the main PLL */
    RCC->CR |= RCC_CR_PLLON;

    /* Wait till the main PLL is ready */
    while((RCC->CR & RCC_CR_PLLRDY) == 0)
    {
    }
   
    /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
    FLASH->ACR = FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;

    /* Select the main PLL as system clock source */
    RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
    RCC->CFGR |= RCC_CFGR_SW_PLL;

    /* Wait till the main PLL is used as system clock source */
    while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
    {
    }
  }
  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 */
  }

}

/**
  * @brief  Setup the external memory controller. Called in startup_stm32f4xx.s
  *          before jump to __main
  * @param  None
  * @retval None
  */
#ifdef DATA_IN_ExtSRAM
/**
  * @brief  Setup the external memory controller.
  *         Called in startup_stm32f4xx.s before jump to main.
  *         This function configures the external SRAM mounted on STM324xG_EVAL board
  *         This SRAM will be used as program data memory (including heap and stack).
  * @param  None
  * @retval None
  */
void SystemInit_ExtMemCtl(void)
{
/*-- GPIOs Configuration -----------------------------------------------------*/
/*
+-------------------+--------------------+------------------+------------------+
+                       SRAM pins assignment                                   +
+-------------------+--------------------+------------------+------------------+
| PD0  <-> FSMC_D2  | PE0  <-> FSMC_NBL0 | PF0  <-> FSMC_A0 | PG0 <-> FSMC_A10 |
| PD1  <-> FSMC_D3  | PE1  <-> FSMC_NBL1 | PF1  <-> FSMC_A1 | PG1 <-> FSMC_A11 |
| PD4  <-> FSMC_NOE | PE3  <-> FSMC_A19  | PF2  <-> FSMC_A2 | PG2 <-> FSMC_A12 |
| PD5  <-> FSMC_NWE | PE4  <-> FSMC_A20  | PF3  <-> FSMC_A3 | PG3 <-> FSMC_A13 |
| PD8  <-> FSMC_D13 | PE7  <-> FSMC_D4   | PF4  <-> FSMC_A4 | PG4 <-> FSMC_A14 |
| PD9  <-> FSMC_D14 | PE8  <-> FSMC_D5   | PF5  <-> FSMC_A5 | PG5 <-> FSMC_A15 |
| PD10 <-> FSMC_D15 | PE9  <-> FSMC_D6   | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
| PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7   | PF13 <-> FSMC_A7 |------------------+
| PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8   | PF14 <-> FSMC_A8 |
| PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9   | PF15 <-> FSMC_A9 |
| PD14 <-> FSMC_D0  | PE13 <-> FSMC_D10  |------------------+
| PD15 <-> FSMC_D1  | PE14 <-> FSMC_D11  |
|                   | PE15 <-> FSMC_D12  |
+-------------------+--------------------+
*/
   /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
  RCC->AHB1ENR   = 0x00000078;
 
  /* Connect PDx pins to FSMC Alternate function */
  GPIOD->AFR[0]  = 0x00cc00cc;
  GPIOD->AFR[1]  = 0xcc0ccccc;
  /* Configure PDx pins in Alternate function mode */ 
  GPIOD->MODER   = 0xaaaa0a0a;
  /* Configure PDx pins speed to 100 MHz */ 
  GPIOD->OSPEEDR = 0xffff0f0f;
  /* Configure PDx pins Output type to push-pull */ 
  GPIOD->OTYPER  = 0x00000000;
  /* No pull-up, pull-down for PDx pins */
  GPIOD->PUPDR   = 0x00000000;

  /* Connect PEx pins to FSMC Alternate function */
  GPIOE->AFR[0]  = 0xc00cc0cc;
  GPIOE->AFR[1]  = 0xcccccccc;
  /* Configure PEx pins in Alternate function mode */
  GPIOE->MODER   = 0xaaaa828a;
  /* Configure PEx pins speed to 100 MHz */
  GPIOE->OSPEEDR = 0xffffc3cf;
  /* Configure PEx pins Output type to push-pull */ 
  GPIOE->OTYPER  = 0x00000000;
  /* No pull-up, pull-down for PEx pins */
  GPIOE->PUPDR   = 0x00000000;

  /* Connect PFx pins to FSMC Alternate function */
  GPIOF->AFR[0]  = 0x00cccccc;
  GPIOF->AFR[1]  = 0xcccc0000;
  /* Configure PFx pins in Alternate function mode */   
  GPIOF->MODER   = 0xaa000aaa;
  /* Configure PFx pins speed to 100 MHz */
  GPIOF->OSPEEDR = 0xff000fff;
  /* Configure PFx pins Output type to push-pull */ 
  GPIOF->OTYPER  = 0x00000000;
  /* No pull-up, pull-down for PFx pins */
  GPIOF->PUPDR   = 0x00000000;

  /* Connect PGx pins to FSMC Alternate function */
  GPIOG->AFR[0]  = 0x00cccccc;
  GPIOG->AFR[1]  = 0x000000c0;
  /* Configure PGx pins in Alternate function mode */
  GPIOG->MODER   = 0x00080aaa;
  /* Configure PGx pins speed to 100 MHz */
  GPIOG->OSPEEDR = 0x000c0fff;
  /* Configure PGx pins Output type to push-pull */ 
  GPIOG->OTYPER  = 0x00000000;
  /* No pull-up, pull-down for PGx pins */
  GPIOG->PUPDR   = 0x00000000;
 
/*-- FSMC Configuration ------------------------------------------------------*/
  /* Enable the FSMC interface clock */
  RCC->AHB3ENR         = 0x00000001;

  /* Configure and enable Bank1_SRAM2 */
  FSMC_Bank1->BTCR[2]  = 0x00001015;
  FSMC_Bank1->BTCR[3]  = 0x00010603;
  FSMC_Bank1E->BWTR[2] = 0x0fffffff;
/*
  Bank1_SRAM2 is configured as follow:

  p.FSMC_AddressSetupTime = 3;
  p.FSMC_AddressHoldTime = 0;
  p.FSMC_DataSetupTime = 6;
  p.FSMC_BusTurnAroundDuration = 1;
  p.FSMC_CLKDivision = 0;
  p.FSMC_DataLatency = 0;
  p.FSMC_AccessMode = FSMC_AccessMode_A;

  FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
  FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
  FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM;
  FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
  FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
  FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; 
  FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
  FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
  FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
  FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
  FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
  FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
  FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
  FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
  FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
*/ 
}
#endif /* DATA_IN_ExtSRAM */


/**
  * @}
  */

/**
  * @}
  */
 
/**
  * @}
  */   
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 24 Haziran 2014, 15:56:11
tamam hocam siz ne yapmak istiyorsunuz, bu dosyayı ekleyip systeminit çağıracaksınız
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 24 Haziran 2014, 16:34:22
İşlemciyi bir türlü 168mhzde koşturamadım.Çıldırtacak yahu.168mhz de koşan programı inceliyorum noktasına kadar aynı.Ama olmuyor.Benim programım 168mhzde koşmuyor.

Clock Config Tool ile yapıyorum birde.Sorun nedir ki?Denemelerimi Stm32f4 disco ile yapıyorum.
Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 24 Haziran 2014, 17:04:14
Derleyicin nedir
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 24 Haziran 2014, 17:06:28
Gcc arm. Ide emblocks
Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 24 Haziran 2014, 17:06:31
Biryerlere HSE_VALUE=8000000 yazdin mi
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 24 Haziran 2014, 17:07:19
Evet
Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 24 Haziran 2014, 17:08:20
168 de calismadigini nereden biliyorsunuz
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 24 Haziran 2014, 17:09:23

    RCC_GetClocksFreq(&RCC_Clock); fonksiyonunu çağırıyorum. Rcc_Clock debugda görüntüleniyor.Oradan..
Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 24 Haziran 2014, 17:18:43
Kac goruyorsun
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 24 Haziran 2014, 17:23:04
525000000 görüyordum.stm32f4xx.h dosyasında yer alan #define HSE_VALUE    ((uint32_t)25000000) kısmını 8 mhz yapıp derledim.168mhz.Ancak ben bir yerlerde yer alan aynı değeri 8mhz yaptığıma adım gibi eminim.Bu dosyadaki gibi #ifendef içinde değildi.Hangi dosya olduğunu bulamadım şimdi.Ama şuan için olması gerektiği gibi.Bu clokc ayarlarıyla ilgili çok kafa karıştırıcı noktadayım şuanda.Beynim sulandı diyebilirim.Adım adım ne yapmak gerek?
Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 24 Haziran 2014, 18:11:39
Hocam Arayüz Ne Kullanıyorsun, Keil mi ?
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 25 Haziran 2014, 08:19:12
Alıntı yapılan: muhittin_kaplan - 24 Haziran 2014, 18:11:39
Hocam Arayüz Ne Kullanıyorsun, Keil mi ?

Alıntı yapılan: yldzelektronik - 24 Haziran 2014, 17:06:28
Gcc arm. Ide emblocks
Başlık: Ynt: Stm32f10x
Gönderen: muhittin_kaplan - 25 Haziran 2014, 11:51:35
Hocam kafaniz karismasin. Yapmanizbgereken dosyanin yani clokc ayarlarinin yapildigi dosyayi degistirip 8mhz icin define yapmaniz.
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 25 Haziran 2014, 13:09:43
Alıntı yapılan: muhittin_kaplan - 25 Haziran 2014, 11:51:35
Hocam kafaniz karismasin. Yapmanizbgereken dosyanin yani clokc ayarlarinin yapildigi dosyayi degistirip 8mhz icin define yapmaniz.

Anladım hocam.Teşekkürler.

Bir de arkadaşlar timer ile ilgili sormak istediğim şeyler var.

Bu seri denetleyicilerde var olan timerlar için çok sayıda fonksiyon var belli.Ancak orada da bir karışıklık var.Çünkü bir timerin birden çok kanalı vs oluyor.Bir sürü fonksiyon var.Bir timer ile sadece sayıcı yapamaz mıyım?
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 26 Haziran 2014, 15:23:45
GPIO register yapısını anlamamıştım.Ancak tekrar tekrar ref man den bakınca daha da netleşti.

Anladığım kadarıyla her port için registerler var;

GPIOA-MODER
GPIOA-OUTTYPE
GPIOA-SPEED
GPIOA-PUPD
GPIOA-IDR
GPIOA-ODR
GPIOA-BSR
GPIOA-LCK
GPIOA-AFRL
GPIOA-AFRH
Bütün portlar için bunlar var.Doğru mu anladım acaba?
Başlık: Ynt: Stm32f10x
Gönderen: Mucit23 - 26 Haziran 2014, 20:13:29
Datasheette hepsi ayrı ayrı anlatılmıyor zaten GPIOX-MODER şeklinde GPIO MODER Registerine değiniliyor

Keilde Aynı registere ulaşmak için
GPIOA->MODER
GPIOB->MODER
şeklinde kullanıyorsun.

Dediğin doğru.
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 29 Haziran 2014, 16:03:03
Herkeze hayırlı ramazanlar.

Keil ile proje oluşturmaya çabalıyorum.Ancak bir türlü başarılı olamadım.Kullandığım library STM32F4xx_DSP_StdPeriph_Lib_V1.3.0. Bir proje oluşturmayı denediğimde f429 için olan dosyaları da derlediğinden o çip ile ilgili dosyalarda hata alıyorum.Acaba hangi library kullanmak gerek?Nasıl proje oluşturabilirim?
Başlık: Ynt: Stm32f10x
Gönderen: musaak - 29 Haziran 2014, 19:55:19
Alıntı yapılan: yldzelektronik - 29 Haziran 2014, 16:03:03
Herkeze hayırlı ramazanlar.

Keil ile proje oluşturmaya çabalıyorum.Ancak bir türlü başarılı olamadım.Kullandığım library STM32F4xx_DSP_StdPeriph_Lib_V1.3.0. Bir proje oluşturmayı denediğimde f429 için olan dosyaları da derlediğinden o çip ile ilgili dosyalarda hata alıyorum.Acaba hangi library kullanmak gerek?Nasıl proje oluşturabilirim?

hocam ne hatası alıyorsunuz.
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 30 Haziran 2014, 16:03:58
Stm32f407 için kullandığınız kütüphanenin versiyonu nedir?Yayında olan v1.3 ancak ben bu kütüphane ile bir türlü başarılı derleme yapamıyorum.Sürekli dma2d ve stm32f429 serisinde gördüğüm donanımların .h ve .c dosyalarında hata veriyor. Sizler de aynı sorunu yaşıyor musunuz?
Başlık: Ynt: Stm32f10x
Gönderen: sseedat - 30 Haziran 2014, 16:35:37
verdiği hataların çıktısı varmı paylaşırsanız ne olduğu hakkında fikir yürütebiliriz belki
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 30 Haziran 2014, 17:12:47

Rebuild target 'Stm32f4xx_Usart'
assembling startup_stm32f4xx.s...
compiling main.c...
compiling stm32f4xx_it.c...
compiling system_stm32f4xx.c...
compiling misc.c...
compiling stm32f4xx_adc.c...
compiling stm32f4xx_can.c...
compiling stm32f4xx_crc.c...
compiling stm32f4xx_cryp.c...
compiling stm32f4xx_cryp_aes.c...
compiling stm32f4xx_cryp_des.c...
compiling stm32f4xx_cryp_tdes.c...
compiling stm32f4xx_dac.c...
compiling stm32f4xx_dbgmcu.c...
compiling stm32f4xx_dcmi.c...
compiling stm32f4xx_dma.c...
compiling stm32f4xx_dma2d.c...
..\Library\src\stm32f4xx_dma2d.c(142): error:  #20: identifier "DMA2D" is undefined
..\Library\src\stm32f4xx_dma2d.c(146): error:  #20: identifier "DMA2D_OPFCCR_CM" is undefined
..\Library\src\stm32f4xx_dma2d.c(196): error:  #20: identifier "DMA2D_OOR_LO" is undefined
..\Library\src\stm32f4xx_dma2d.c(201): error:  #20: identifier "DMA2D_NLR_NL" is undefined
..\Library\src\stm32f4xx_dma2d.c(201): error:  #20: identifier "DMA2D_NLR_PL" is undefined
..\Library\src\stm32f4xx_dma2d.c(245): error:  #20: identifier "DMA2D" is undefined
..\Library\src\stm32f4xx_dma2d.c(245): error:  #20: identifier "DMA2D_CR_START" is undefined
..\Library\src\stm32f4xx_dma2d.c(257): error:  #20: identifier "DMA2D" is undefined
..\Library\src\stm32f4xx_dma2d.c(257): error:  #20: identifier "DMA2D_CR_ABORT" is undefined
..\Library\src\stm32f4xx_dma2d.c(275): error:  #20: identifier "DMA2D" is undefined
..\Library\src\stm32f4xx_dma2d.c(275): error:  #20: identifier "DMA2D_CR_SUSP" is undefined
..\Library\src\stm32f4xx_dma2d.c(280): error:  #20: identifier "DMA2D" is undefined
..\Library\src\stm32f4xx_dma2d.c(280): error:  #20: identifier "DMA2D_CR_SUSP" is undefined
..\Library\src\stm32f4xx_dma2d.c(313): error:  #20: identifier "DMA2D" is undefined
..\Library\src\stm32f4xx_dma2d.c(316): error:  #20: identifier "DMA2D_FGOR_LO" is undefined
..\Library\src\stm32f4xx_dma2d.c(329): error:  #20: identifier "DMA2D_FGCOLR_BLUE" is undefined
..\Library\src\stm32f4xx_dma2d.c(329): error:  #20: identifier "DMA2D_FGCOLR_GREEN" is undefined
..\Library\src\stm32f4xx_dma2d.c(329): error:  #20: identifier "DMA2D_FGCOLR_RED" is undefined
..\Library\src\stm32f4xx_dma2d.c(410): error:  #20: identifier "DMA2D" is undefined
..\Library\src\stm32f4xx_dma2d.c(413): error:  #20: identifier "DMA2D_BGOR_LO" is undefined
..\Library\src\stm32f4xx_dma2d.c(426): error:  #20: identifier "DMA2D_BGCOLR_BLUE" is undefined
..\Library\src\stm32f4xx_dma2d.c(426): error:  #20: identifier "DMA2D_BGCOLR_GREEN" is undefined
..\Library\src\stm32f4xx_dma2d.c(426): error:  #20: identifier "DMA2D_BGCOLR_RED" is undefined
..\Library\src\stm32f4xx_dma2d.c(493): error:  #20: identifier "DMA2D" is undefined
..\Library\src\stm32f4xx_dma2d.c(493): error:  #20: identifier "DMA2D_FGPFCCR_START" is undefined
..\Library\src\stm32f4xx_dma2d.c(498): error:  #20: identifier "DMA2D" is undefined
..\Library\src\stm32f4xx_dma2d.c(498): error:  #20: identifier "DMA2D_FGPFCCR_START" is undefined
..\Library\src\stm32f4xx_dma2d.c(517): error:  #20: identifier "DMA2D" is undefined
..\Library\src\stm32f4xx_dma2d.c(517): error:  #20: identifier "DMA2D_BGPFCCR_START" is undefined
..\Library\src\stm32f4xx_dma2d.c(522): error:  #20: identifier "DMA2D" is undefined
compiling stm32f4xx_exti.c...
compiling stm32f4xx_flash.c...
..\Library\src\stm32f4xx_flash.c(507): warning:  #550-D: variable "tmp_psize" was set but never used
..\Library\src\stm32f4xx_flash.c(1248): error:  #20: identifier "FLASH_OPTCR_BFB2" is undefined
compiling stm32f4xx_fmc.c...
..\Library\src\stm32f4xx_fmc.c(138): error:  #20: identifier "FMC_Bank1" is undefined
..\Library\src\stm32f4xx_fmc.c(143): error:  #20: identifier "FMC_Bank1" is undefined
..\Library\src\stm32f4xx_fmc.c(145): error:  #20: identifier "FMC_Bank1" is undefined
..\Library\src\stm32f4xx_fmc.c(146): error:  #20: identifier "FMC_Bank1E" is undefined
..\Library\src\stm32f4xx_fmc.c(185): error:  #20: identifier "FMC_Bank1" is undefined
..\Library\src\stm32f4xx_fmc.c(236): error:  #20: identifier "FMC_Bank1E" is undefined
..\Library\src\stm32f4xx_fmc.c(246): error:  #20: identifier "FMC_Bank1E" is undefined
..\Library\src\stm32f4xx_fmc.c(310): error:  #20: identifier "FMC_Bank1" is undefined
..\Library\src\stm32f4xx_fmc.c(315): error:  #20: identifier "FMC_Bank1" is undefined
..\Library\src\stm32f4xx_fmc.c(383): error:  #20: identifier "FMC_Bank2" is undefined
..\Library\src\stm32f4xx_fmc.c(392): error:  #20: identifier "FMC_Bank3" is undefined
..\Library\src\stm32f4xx_fmc.c(451): error:  #20: identifier "FMC_Bank2" is undefined
..\Library\src\stm32f4xx_fmc.c(458): error:  #20: identifier "FMC_Bank3" is undefined
..\Library\src\stm32f4xx_fmc.c(510): error:  #20: identifier "FMC_Bank2" is undefined
..\Library\src\stm32f4xx_fmc.c(514): error:  #20: identifier "FMC_Bank3" is undefined
..\Library\src\stm32f4xx_fmc.c(522): error:  #20: identifier "FMC_Bank2" is undefined
..\Library\src\stm32f4xx_fmc.c(526): error:  #20: identifier "FMC_Bank3" is undefined
..\Library\src\stm32f4xx_fmc.c(550): error:  #20: identifier "FMC_Bank2" is undefined
..\Library\src\stm32f4xx_fmc.c(554): error:  #20: identifier "FMC_Bank3" is undefined
..\Library\src\stm32f4xx_fmc.c(562): error:  #20: identifier "FMC_Bank2" is undefined
..\Library\src\stm32f4xx_fmc.c(566): error:  #20: identifier "FMC_Bank3" is undefined
..\Library\src\stm32f4xx_fmc.c(586): error:  #20: identifier "FMC_Bank2" is undefined
..\Library\src\stm32f4xx_fmc.c(591): error:  #20: identifier "FMC_Bank3" is undefined
..\Library\src\stm32f4xx_fmc.c(646): error:  #20: identifier "FMC_Bank4" is undefined
..\Library\src\stm32f4xx_fmc.c(682): error:  #20: identifier "FMC_Bank4" is undefined
..\Library\src\stm32f4xx_fmc.c(745): error:  #20: identifier "FMC_Bank4" is undefined
..\Library\src\stm32f4xx_fmc.c(750): error:  #20: identifier "FMC_Bank4" is undefined
..\Library\src\stm32f4xx_fmc.c(815): error:  #20: identifier "FMC_Bank5_6" is undefined
..\Library\src\stm32f4xx_fmc.c(874): error:  #20: identifier "FMC_Bank5_6" is undefined
..\Library\src\stm32f4xx_fmc.c(882): error:  #20: identifier "FMC_Bank5_6" is undefined
compiling stm32f4xx_fsmc.c...
compiling stm32f4xx_gpio.c...
..\Library\src\stm32f4xx_gpio.c(178): error:  #20: identifier "GPIOJ" is undefined
..\Library\src\stm32f4xx_gpio.c(185): error:  #20: identifier "GPIOK" is undefined
compiling stm32f4xx_hash.c...
compiling stm32f4xx_hash_md5.c...
compiling stm32f4xx_hash_sha1.c...
compiling stm32f4xx_i2c.c...
compiling stm32f4xx_iwdg.c...
compiling stm32f4xx_ltdc.c...
..\Library\inc\stm32f4xx_ltdc.h(487): error:  #20: identifier "LTDC_Layer_TypeDef" is undefined
..\Library\inc\stm32f4xx_ltdc.h(489): error:  #20: identifier "LTDC_Layer_TypeDef" is undefined
..\Library\inc\stm32f4xx_ltdc.h(493): error:  #20: identifier "LTDC_Layer_TypeDef" is undefined
..\Library\inc\stm32f4xx_ltdc.h(495): error:  #20: identifier "LTDC_Layer_TypeDef" is undefined
..\Library\inc\stm32f4xx_ltdc.h(496): error:  #20: identifier "LTDC_Layer_TypeDef" is undefined
..\Library\inc\stm32f4xx_ltdc.h(498): error:  #20: identifier "LTDC_Layer_TypeDef" is undefined
..\Library\inc\stm32f4xx_ltdc.h(499): error:  #20: identifier "LTDC_Layer_TypeDef" is undefined
..\Library\inc\stm32f4xx_ltdc.h(500): error:  #20: identifier "LTDC_Layer_TypeDef" is undefined
..\Library\inc\stm32f4xx_ltdc.h(501): error:  #20: identifier "LTDC_Layer_TypeDef" is undefined
..\Library\inc\stm32f4xx_ltdc.h(502): error:  #20: identifier "LTDC_Layer_TypeDef" is undefined
..\Library\src\stm32f4xx_ltdc.c(167): error:  #20: identifier "LTDC" is undefined
..\Library\src\stm32f4xx_ltdc.c(167): error:  #20: identifier "LTDC_SSCR_VSH" is undefined
..\Library\src\stm32f4xx_ltdc.c(167): error:  #20: identifier "LTDC_SSCR_HSW" is undefined
..\Library\src\stm32f4xx_ltdc.c(172): error:  #20: identifier "LTDC_BPCR_AVBP" is undefined
..\Library\src\stm32f4xx_ltdc.c(172): error:  #20: identifier "LTDC_BPCR_AHBP" is undefined
..\Library\src\stm32f4xx_ltdc.c(177): error:  #20: identifier "LTDC_AWCR_AAH" is undefined
..\Library\src\stm32f4xx_ltdc.c(177): error:  #20: identifier "LTDC_AWCR_AAW" is undefined
..\Library\src\stm32f4xx_ltdc.c(182): error:  #20: identifier "LTDC_TWCR_TOTALH" is undefined
..\Library\src\stm32f4xx_ltdc.c(182): error:  #20: identifier "LTDC_TWCR_TOTALW" is undefined
..\Library\src\stm32f4xx_ltdc.c(194): error:  #20: identifier "LTDC_BCCR_BCBLUE" is undefined
..\Library\src\stm32f4xx_ltdc.c(194): error:  #20: identifier "LTDC_BCCR_BCGREEN" is undefined
..\Library\src\stm32f4xx_ltdc.c(194): error:  #20: identifier "LTDC_BCCR_BCRED" is undefined
..\Library\src\stm32f4xx_ltdc.c(240): error:  #20: identifier "LTDC" is undefined
..\Library\src\stm32f4xx_ltdc.c(240): error:  #20: identifier "LTDC_GCR_LTDCEN" is undefined
..\Library\src\stm32f4xx_ltdc.c(245): error:  #20: identifier "LTDC" is undefined
..\Library\src\stm32f4xx_ltdc.c(245): error:  #20: identifier "LTDC_GCR_LTDCEN" is undefined
..\Library\src\stm32f4xx_ltdc.c(264): error:  #20: identifier "LTDC" is undefined
..\Library\src\stm32f4xx_ltdc.c(264): error:  #20: identifier "LTDC_GCR_DTEN" is undefined
..\Library\src\stm32f4xx_ltdc.c(269): error:  #20: identifier "LTDC" is undefined
..\Library\src\stm32f4xx_ltdc.c(269): error:  #20: identifier "LTDC_GCR_DTEN" is undefined
compiling stm32f4xx_pwr.c...
..\Library\src\stm32f4xx_pwr.c(463): error:  #20: identifier "PWR_CR_UDEN" is undefined
..\Library\src\stm32f4xx_pwr.c(468): error:  #20: identifier "PWR_CR_UDEN" is undefined
compiling stm32f4xx_rcc.c...
..\Library\src\stm32f4xx_rcc.c(231): error:  #136: struct "<unnamed>" has no field "PLLSAICFGR"
..\Library\src\stm32f4xx_rcc.c(240): error:  #136: struct "<unnamed>" has no field "DCKCFGR"
..\Library\src\stm32f4xx_rcc.c(604): error:  #136: struct "<unnamed>" has no field "PLLSAICFGR"
..\Library\src\stm32f4xx_rcc.c(1250): error:  #136: struct "<unnamed>" has no field "DCKCFGR"
..\Library\src\stm32f4xx_rcc.c(1253): error:  #20: identifier "RCC_DCKCFGR_PLLI2SDIVQ" is undefined
..\Library\src\stm32f4xx_rcc.c(1259): error:  #136: struct "<unnamed>" has no field "DCKCFGR"
..\Library\src\stm32f4xx_rcc.c(1282): error:  #136: struct "<unnamed>" has no field "DCKCFGR"
..\Library\src\stm32f4xx_rcc.c(1285): error:  #20: identifier "RCC_DCKCFGR_PLLSAIDIVQ" is undefined
..\Library\src\stm32f4xx_rcc.c(1291): error:  #136: struct "<unnamed>" has no field "DCKCFGR"
..\Library\src\stm32f4xx_rcc.c(1318): error:  #136: struct "<unnamed>" has no field "DCKCFGR"
..\Library\src\stm32f4xx_rcc.c(1321): error:  #20: identifier "RCC_DCKCFGR_SAI1ASRC" is undefined
..\Library\src\stm32f4xx_rcc.c(1327): error:  #136: struct "<unnamed>" has no field "DCKCFGR"
..\Library\src\stm32f4xx_rcc.c(1354): error:  #136: struct "<unnamed>" has no field "DCKCFGR"
..\Library\src\stm32f4xx_rcc.c(1357): error:  #20: identifier "RCC_DCKCFGR_SAI1BSRC" is undefined
..\Library\src\stm32f4xx_rcc.c(1363): error:  #136: struct "<unnamed>" has no field "DCKCFGR"
..\Library\src\stm32f4xx_rcc.c(1387): error:  #136: struct "<unnamed>" has no field "DCKCFGR"
..\Library\src\stm32f4xx_rcc.c(1390): error:  #20: identifier "RCC_DCKCFGR_PLLSAIDIVR" is undefined
..\Library\src\stm32f4xx_rcc.c(1396): error:  #136: struct "<unnamed>" has no field "DCKCFGR"
compiling stm32f4xx_rng.c...
compiling stm32f4xx_rtc.c...
compiling stm32f4xx_sai.c...
..\Library\inc\stm32f4xx_sai.h(562): error:  #20: identifier "SAI_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(565): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(566): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(567): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(572): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(573): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(574): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(575): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(576): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(577): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(578): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(579): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(582): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(583): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(586): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(589): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(590): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(591): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(592): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(593): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(594): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\inc\stm32f4xx_sai.h(595): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\src\stm32f4xx_sai.c(182): error:  #20: identifier "SAI_TypeDef" is undefined
..\Library\src\stm32f4xx_sai.c(205): error:  #20: identifier "SAI_Block_TypeDef" is undefined
..\Library\src\stm32f4xx_sai.c(226): error:  #132: expression must have pointer-to-struct-or-union type
..\Library\src\stm32f4xx_sai.c(246): error:  #132: expression must have pointer-to-struct-or-union type
..\Library\src\stm32f4xx_sai.c(250): error:  #132: expression must have pointer-to-struct-or-union type
..\Library\src\stm32f4xx_sai.c(252): error:  #20: identifier "SAI_xCR2_FTH" is undefined
..\Library\src\stm32f4xx_sai.c(257): error:  #132: expression must have pointer-to-struct-or-union type
..\Library\src\stm32f4xx_sai.c(272): error:  #20: identifier "SAI_Block_TypeDef" is undefined
compiling stm32f4xx_sdio.c...
compiling stm32f4xx_spi.c...
compiling stm32f4xx_syscfg.c...
compiling stm32f4xx_tim.c...
compiling stm32f4xx_usart.c...
compiling stm32f4xx_wwdg.c...
Target not created

http://speedy.sh/HHXYA/Usart.rar (http://speedy.sh/HHXYA/Usart.rar) proje dosyasını buraya kopyaladım.Nerede hata yaptığımı anlamadım.Daha doğrusu v1.3 kütüphaneyi neden kullanamıyorum?
Başlık: Ynt: Stm32f10x
Gönderen: sseedat - 30 Haziran 2014, 17:19:26
ben sorunsuz belirttiğiniz kütüphane versiyonunu kullanıyorum sıkıntı çıkmadı.
dma ile ilgili dosyaları projeye dahil ettiniz mi. .

Başlık: Ynt: Stm32f10x
Gönderen: pisayisi - 30 Haziran 2014, 19:12:35
Kütüphane dosyaların düzgün yapılandırılmamış gibi görünüyor , aşağıda derlenmiş şablon projeyi dene senin main.c yi ekledim sorunsuz derleniyor...

http://speedy.sh/ccnnT/stm32f4-proje-sablon-uart.rar (http://speedy.sh/ccnnT/stm32f4-proje-sablon-uart.rar)
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 02 Temmuz 2014, 11:11:07
Alıntı yapılan: pisayisi - 30 Haziran 2014, 19:12:35
Kütüphane dosyaların düzgün yapılandırılmamış gibi görünüyor , aşağıda derlenmiş şablon projeyi dene senin main.c yi ekledim sorunsuz derleniyor...

http://speedy.sh/ccnnT/stm32f4-proje-sablon-uart.rar (http://speedy.sh/ccnnT/stm32f4-proje-sablon-uart.rar)

Teşekkürler. Çalışıyor.Sen verdiğin şablon ile istediğim şekilde daha düzenli proje dosyası oluşturup template gibi kullanıyorum.Ancak benim verdiğimde ne gibi düzensizlik vardı?Yani neden derleme hatası alıyordum?
Başlık: Ynt: Stm32f10x
Gönderen: Mucit23 - 02 Temmuz 2014, 14:21:18
Alıntı yapılan: yldzelektronik - 02 Temmuz 2014, 11:11:07
Teşekkürler. Çalışıyor.Sen verdiğin şablon ile istediğim şekilde daha düzenli proje dosyası oluşturup template gibi kullanıyorum.Ancak benim verdiğimde ne gibi düzensizlik vardı?Yani neden derleme hatası alıyordum?

Mutlaka bir yerde eksik birşeyler yapıyorsundur. Bence indirdiğin template projeye bakarak kendin yeni bir proje oluşturmaya çalış. Zamanında ben öyle yapa yapa öğrenmiştim.

Aslında STD_Peripheral_Library kullanılarak sıfırdan proje kurulumuna dair forumda hiçbir anlatım yok. Bu bence bir eksiklik
Başlık: Ynt: Stm32f10x
Gönderen: yldzelektronik - 03 Temmuz 2014, 09:32:43
Alıntı yapılan: Mucit23 - 02 Temmuz 2014, 14:21:18
Mutlaka bir yerde eksik birşeyler yapıyorsundur....

Orası kesin de nerede ne hata yaptığımı bılmaya çalışıyorum. Ki aynı hataları tekrarlamayayım.

Bu arada dma kullanımından bahsedebilir misiniz?

Adc ile dma kullanarak 10 elemanlı diziye veriyi yazıp, veriyi 30 elemanlı bir stringe çevirmek ve yine dma ile usart üzerinden göndermek istiyorum.

Normalde adcden veriyi okuyup diziye yazdıktan sonra kesme oluşturuyorum.O kesmede median filtreden geçirip usart dmayı açmak ve adc dma yı kapamak istiyorum.Usart dma veriyi yolladıktan sonra kendini kapatıp adc dmayı açsın istiyorum.

Adc dma ile veriyi 10 elemanlı diziye yazıyorum.Ama usart çalışmıyor.

Bir de incelediğim örnek programda gariplik olduğunu düşünmeye başladım.Adc 12bit.Değişken 32 bit.Okuduğum değerler ilginç değerler. Bir türlü doğru gerilimi hesaplayamadım.


#include "stdio.h"
#include "stdlib.h"
#include <stm32f4xx.h>
#include <misc.h> // I recommend you have a look at these in the ST firmware folder
#include <stm32f4xx_usart.h>
#include "median.c"

#define MAX_STRLEN 12 // this is the maximum string length of our string in characters
#define ADC_CDR_ADDRESS    ((uint32_t)0x40012308)
#define USART3_Address ((uint32_t)0x40004804)
uint32_t ADC_MedianResult = 0;
uint32_t AdcRawValue[10];
unsigned char Flag = 0;
char MedianResult_ASCII[30];
volatile char received_string[MAX_STRLEN+1]; // this will hold the recieved string

void Delay(__IO uint32_t nCount) {
  while(nCount--) {
  }
}


void init_USART3(uint32_t baudrate){
GPIO_InitTypeDef GPIO_InitStruct; // this is for the GPIO pins used as TX and RX
USART_InitTypeDef USART_InitStruct; // this is for the USART1 initilization
NVIC_InitTypeDef NVIC_InitStructure; // this is used to configure the NVIC (nested vector interrupt controller)
DMA_InitTypeDef DMA_InitStructure;

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 | RCC_AHB1Periph_GPIOB, ENABLE);

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; // Pins 6 (TX) and 7 (RX) are used
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; // the pins are configured as alternate function so the USART peripheral has access to them
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; // this defines the IO speed and has nothing to do with the baudrate!
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; // this defines the output type as push pull mode (as opposed to open drain)
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; // this activates the pullup resistors on the IO pins
GPIO_Init(GPIOB, &GPIO_InitStruct); // now all the values are passed to the GPIO_Init() function which sets the GPIO registers

GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_USART3); //
GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_USART3);

USART_InitStruct.USART_BaudRate = baudrate; // the baudrate is set to the value we passed into this init function
USART_InitStruct.USART_WordLength = USART_WordLength_8b;// we want the data frame size to be 8 bits (standard)
USART_InitStruct.USART_StopBits = USART_StopBits_1; // we want 1 stop bit (standard)
USART_InitStruct.USART_Parity = USART_Parity_No; // we don't want a parity bit (standard)
USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // we don't want flow control (standard)
USART_InitStruct.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; // we want to enable the transmitter and the receiver
USART_Init(USART3, &USART_InitStruct); // again all the properties are passed to the USART_Init function which takes care of all the bit setting

USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); // enable the USART3 receive interrupt

NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; // we want to configure the USART1 interrupts
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;// this sets the priority group of the USART1 interrupts
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; // this sets the subpriority inside the group
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; // the USART1 interrupts are globally enabled
NVIC_Init(&NVIC_InitStructure); // the properties are passed to the NVIC_Init function which takes care of the low level stuff

DMA_InitStructure.DMA_Channel= DMA_Channel_4;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)USART3_Address;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)MedianResult_ASCII;
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_InitStructure.DMA_BufferSize = 30;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_Medium ;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA1_Stream3, & DMA_InitStructure);

DMA_ITConfig(DMA1_Stream3,DMA_IT_TC,ENABLE);

DMA_Cmd(DMA1_Stream3, ENABLE);

NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream3_IRQn; // we want to configure the USART1 interrupts
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;// this sets the priority group of the USART1 interrupts
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; // this sets the subpriority inside the group
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; // the USART1 interrupts are globally enabled
NVIC_Init(&NVIC_InitStructure); // the properties are passed to the NVIC_Init function which takes care of the low level stuff

// finally this enables the complete USART1 peripheral
USART_Cmd(USART3, ENABLE);
}



void init_ADC(){
ADC_InitTypeDef ADC_InitStructure;
ADC_CommonInitTypeDef ADC_COmmonInitStructure;
DMA_InitTypeDef DMA_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure; // this is used to configure the NVIC (nested vector interrupt controller)

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 | RCC_AHB1Periph_GPIOA,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2 | RCC_APB2Periph_ADC3, ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA,&GPIO_InitStructure);

DMA_InitStructure.DMA_Channel= DMA_Channel_0;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC_CDR_ADDRESS;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)AdcRawValue;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_BufferSize = 10;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA2_Stream0, & DMA_InitStructure);

DMA_ITConfig(DMA2_Stream0,DMA_IT_TC,ENABLE);

NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream0_IRQn; // we want to configure the USART1 interrupts
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;// this sets the priority group of the USART1 interrupts
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; // this sets the subpriority inside the group
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; // the USART1 interrupts are globally enabled
NVIC_Init(&NVIC_InitStructure); // the properties are passed to the NVIC_Init function which takes care of the low level stuff

DMA_Cmd(DMA2_Stream0, ENABLE);

ADC_COmmonInitStructure.ADC_Mode = ADC_TripleMode_Interl;
ADC_COmmonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
ADC_COmmonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_2;
ADC_COmmonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
ADC_CommonInit(&ADC_COmmonInitStructure);

ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConvEdge_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfConversion = 1;
ADC_Init(ADC1, &ADC_InitStructure);

ADC_RegularChannelConfig(ADC1, ADC_Channel_1,1,ADC_SampleTime_3Cycles);

ADC_DMACmd(ADC1,ENABLE);

ADC_Init(ADC2, &ADC_InitStructure);

ADC_RegularChannelConfig(ADC2, ADC_Channel_1,1,ADC_SampleTime_3Cycles);

ADC_Init(ADC3, &ADC_InitStructure);

ADC_RegularChannelConfig(ADC3, ADC_Channel_1,1,ADC_SampleTime_3Cycles);

ADC_MultiModeDMARequestAfterLastTransferCmd(ENABLE);

ADC_Cmd(ADC1, ENABLE);

ADC_Cmd(ADC2, ENABLE);

ADC_Cmd(ADC3, ENABLE);

ADC_SoftwareStartConv(ADC1);
}



void USART_puts(USART_TypeDef* USARTx, volatile char *s){

while(*s){
// wait until data register is empty
while( !(USARTx->SR & 0x00000040) );
USART_SendData(USARTx, *s);
*s++;
}
}


int main(void) {
 
  init_USART3(9600); // initialize USART1 @ 9600 baud
init_ADC();
  USART_puts(USART3, "Init complete! Hello World!\r\n"); // just send a message to indicate that it works

  while (1){ 
    /*
     * You can do whatever you want in here
     */
if(Flag){
sprintf(MedianResult_ASCII, "ADC:%u\r\nGerilim:%f\r\n",ADC_MedianResult,(float)((float)ADC_MedianResult/4096));
USART_puts(USART3,MedianResult_ASCII);
USART_DMACmd(USART3,USART_DMAReq_Tx,ENABLE);
DMA_ITConfig(DMA2_Stream0,DMA_IT_TC,ENABLE);
Flag = 0;
}
  }
}

void DMA1_Stream3_IRQHandler(void){
if(DMA_GetITStatus(DMA1_Stream3,DMA_FLAG_TCIF3)){
DMA_Cmd(DMA1_Stream3, DISABLE);
DMA_Cmd(DMA2_Stream0, ENABLE);
}
}
void DMA2_Stream0_IRQHandler(void){
if(DMA_GetITStatus(DMA2_Stream0,DMA_IT_TCIF0)){
DMA_ITConfig(DMA2_Stream0,DMA_IT_TC,DISABLE);
//DMA_Cmd(DMA2_Stream0, DISABLE);
ADC_MedianResult = wGetMedianFilteredResult(AdcRawValue);
Flag = 1;
}
}

// this is the interrupt request handler (IRQ) for ALL USART1 interrupts
void USART3_IRQHandler(void){

// check if the USART1 receive interrupt flag was set
if( USART_GetITStatus(USART3, USART_IT_RXNE) ){

static uint8_t cnt = 0; // this counter is used to determine the string length
char t = USART3->DR; // the character from the USART1 data register is saved in t

/* check if the received character is not the LF character (used to determine end of string)
* or the if the maximum string length has been been reached
*/
if( (t != '\n') && (cnt < MAX_STRLEN) ){
received_string[cnt] = t;
cnt++;
}
else{ // otherwise reset the character counter and print the received string
cnt = 0;
USART_puts(USART3, received_string);
}
}
}