This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

keil- 10000 samples

I want to take 10000 examples of keil. I can't get char samples [10000] either. Do you have a solution?

My code is below.

#include <stm32f4xx.h>
#include <stm32f4xx_rcc.h>
#include <stm32f4xx_adc.h>
#include <stm32f4xx_gpio.h>

ADC_InitTypeDef ADC_init_structure; //Structure for adc confguration
GPIO_InitTypeDef alper; //Structure for analog input pin

float dum1;
int ms10Ticks; /* counts 1ms timeTicks */

/*----------------------------------------------------------------------------
SysTick_Handler
*----------------------------------------------------------------------------*/
void SysTick_Handler(void) {
ms10Ticks++;
ADC_SoftwareStartConv(ADC1);//ADC1->CR2 |= (1<<30);
}

/*----------------------------------------------------------------------------
MAIN function
*----------------------------------------------------------------------------*/
int main (void) {
char huge samples[10000];
int i=0;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD,ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);

GPIO_StructInit(&alper);
alper.GPIO_Pin = GPIO_Pin_5;//The channel 15 is connected to PC5
alper.GPIO_Mode = GPIO_Mode_AN; //The PC5 pin is configured in analog mode
alper.GPIO_PuPd = GPIO_PuPd_NOPULL; //We don't need any pull up or pull down
GPIO_Init(GPIOC,&alper);//Affecting the port with the initialization structure configuration

//GPIOC->MODER |= (3<<10); // PC5--> ADC.15 input olarak ayarla
//GPIOC->PUPDR = 0x00000000; // pull up-down yok

ADC_DeInit();
ADC_init_structure.ADC_DataAlign = ADC_DataAlign_Right;//data converted will be shifted to right
ADC_init_structure.ADC_Resolution = ADC_Resolution_12b;//Input voltage is converted into a 12bit number giving a maximum value of 4096
ADC_init_structure.ADC_ContinuousConvMode = DISABLE; //the conversion is continuous, the input data is converted once
ADC_init_structure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;//no trigger for conversion
ADC_init_structure.ADC_NbrOfConversion = 1;
ADC_init_structure.ADC_ScanConvMode = DISABLE;//The scan is configured in one channel
ADC_Init(ADC1,&ADC_init_structure);//Initialize ADC with the previous configuration
//Enable ADC conversion
ADC_Cmd(ADC1,ENABLE);
//Select the channel to be read from
ADC_RegularChannelConfig(ADC1,ADC_Channel_15,1,ADC_SampleTime_144Cycles);

SystemCoreClockUpdate(); /* Get Core Clock Frequency */
if (SysTick_Config(SystemCoreClock / 10000)) { /* SysTick 10 msec interrupts */
while (1); /* Capture error */
}


while(1) { /* Loop forever */
if(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC)){//if((ADC1->SR & 0x00000002)){

dum1=(ADC_GetConversionValue(ADC1));
samples[i]=dum1;// BURAYA KODUNU YAZ….örnegi burda aliyor…dum1 içerisine.
i++;
if(i==10000)
i=0;
}
}

}

Parents Reply Children