DMA TC kesmesi sorunu

Başlatan Mucit23, 16 Haziran 2017, 14:30:28

Mucit23

Selamlar

STM32F10x de Timer ile ADC yi tetikleyip DMA ile belirli sayıda örnek alıp bir diziye atıyorum. DMA transfer bittiğinde otomatikmen kesme oluşturması lazım bana ama sadece 1 defa kesme oluşuyor devamı gelmiyor.

İnit ayarlarım bu şekilde
#include "stm32f10x.h"
#include "Adc.h"

uint16_t ADC_ConvertedValue[128];

/*ADC baslanagic ayarlari yuklenme islemini yapar */
void ADC1_Configuration(){
	
		ADC_InitTypeDef ADC_InitStructure;
		GPIO_InitTypeDef GPIO_InitStructure;

		RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE);

		/* ADC pin analog input yapiliyor */
		GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;  
		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
		GPIO_Init(GPIOB, &GPIO_InitStructure);

		ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
		ADC_InitStructure.ADC_ScanConvMode = DISABLE;
		ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
		ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T3_TRGO;
		ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
		ADC_InitStructure.ADC_NbrOfChannel = 1;
		ADC_Init(ADC1, &ADC_InitStructure);

		/*  Ch8 PB0   */ 
		ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 1, ADC_SampleTime_55Cycles5);

		ADC_Cmd(ADC1, ENABLE);
		
		ADC_DMACmd(ADC1,ENABLE);
		
		ADC_ExternalTrigConvCmd(ADC1,ENABLE);

		/* ADC1 Reset Kalibrasyonu yapilacak */
		ADC_ResetCalibration(ADC1);
		/* Kalibrasyon bekleniyor */
		while(ADC_GetResetCalibrationStatus(ADC1));

		/* ADC1 calibrasyonu yapilacak */
		ADC_StartCalibration(ADC1);
		/* Kalibrasyon bekleniyor */
		while(ADC_GetCalibrationStatus(ADC1));
		
}

void DMA1_Configuration(void)
{
		DMA_InitTypeDef DMA_InitStructure;
		NVIC_InitTypeDef NVIC_InitStructure;
		/*DMA Clock Aktif Ediliyor*/
		RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);

		/*  DMA Ayarlar1 Yapiliyor */
		DMA_DeInit(DMA1_Channel1);
		DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
		DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_ConvertedValue;
		DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
		DMA_InitStructure.DMA_BufferSize = 128;
		DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
		DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
		DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
		DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
		DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
		DMA_InitStructure.DMA_Priority = DMA_Priority_High;
		DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
		DMA_Init(DMA1_Channel1, &DMA_InitStructure);
	
		 /* Enable the DMA1 TC Interrupt */
		NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn;
		NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
		NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
		NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
		NVIC_Init(&NVIC_InitStructure);
		
		/* DMA Transfer Complete interrupt Enable*/
		DMA_ITConfig(DMA1_Channel1,DMA1_IT_TC1,ENABLE);	

		/* Enable DMA1 channel1 */
		DMA_Cmd(DMA1_Channel1, ENABLE);
}

void TIM3_Configuration(void)
{
    TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
	  TIM_OCInitTypeDef	TIM_OCInitStructure;
	
    /*Enable TIM3 Clock*/
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);		
	
    TIM_DeInit(TIM3);
    
    TIM_TimeBaseStructure.TIM_Period = 999;	
    TIM_TimeBaseStructure.TIM_Prescaler = 35;
    TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
    TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
	
	  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Toggle;
    TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
    TIM_OCInitStructure.TIM_Pulse = 1;
    TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
    TIM_OC1Init(TIM3, &TIM_OCInitStructure);
	
    TIM_SelectOutputTrigger(TIM3,TIM_TRGOSource_OC1); 
	
    TIM_ARRPreloadConfig(TIM3, ENABLE);	
	
    TIM_Cmd(TIM3, ENABLE);
}

void ADC_init(void)
{
  DMA1_Configuration();
	ADC1_Configuration();
	TIM3_Configuration();
}


DMA1'in kanal1'ini kullanıyorum.

Dediğim gibi Timer ADC ve DMA çalışıyor. İstediğim boyutta örnek alıp diziye atıyor. Fakat kesmede sorun var.

Kesme ayarlarımmı hatalı anlamadım. Fikri olan varmı? Bu durum neden olur?