Stm32f10x

Başlatan yldzelektronik, 16 Haziran 2014, 15:07:21

sseedat

verdiği hataların çıktısı varmı paylaşırsanız ne olduğu hakkında fikir yürütebiliriz belki
Görünmez bir mezarlıktır Zaman...

yldzelektronik

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 proje dosyasını buraya kopyaladım.Nerede hata yaptığımı anlamadım.Daha doğrusu v1.3 kütüphaneyi neden kullanamıyorum?
Kişinin başına gelen hayır Allah'tandır. Kişinin başına gelen şer nefsindendir. Nefislerimizle kendimize zulüm ediyoruz.

sseedat

ben sorunsuz belirttiğiniz kütüphane versiyonunu kullanıyorum sıkıntı çıkmadı.
dma ile ilgili dosyaları projeye dahil ettiniz mi. .

Görünmez bir mezarlıktır Zaman...

pisayisi

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
Murat

yldzelektronik

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

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?
Kişinin başına gelen hayır Allah'tandır. Kişinin başına gelen şer nefsindendir. Nefislerimizle kendimize zulüm ediyoruz.

Mucit23

#50
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

yldzelektronik

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);
		}
	}
}
Kişinin başına gelen hayır Allah'tandır. Kişinin başına gelen şer nefsindendir. Nefislerimizle kendimize zulüm ediyoruz.