When I run this code I don't get into the DMA IQRHandler. I am trying to put the signal, generated in the main, on the DAC output using the DMA. Haven't got any luck so far. Been searching on this problem all day. Any help?
/****************************************************************** Author: Bert Vanoverschelde Revision: v1.0 Summary: DAC/DMA test Date: 21/05/2015 ******************************************************************/ /*INCLUDES*/ #include "stm32f10x_rcc.h" // Keil::Device:StdPeriph Drivers:RCC #include "stm32f10x_tim.h" // Keil::Device:StdPeriph Drivers:TIM #include "stm32f10x_dac.h" // Keil::Device:StdPeriph Drivers:DAC #include "stm32f10x_dma.h" // Keil::Device:StdPeriph Drivers:DMA #include "stm32f10x_gpio.h" // Keil::Device:StdPeriph Drivers:GPIO #include "LED.h" // Keil.MCBSTM32C::Board Support:MCBSTM32C:LED #include "stm32f10x.h" // Device header #include <stdio.h> #include "cmsis_os.h" // ARM::CMSIS:RTOS:Keil RTX #define PERIOD 1152 /*GLOBAL VARIABLES*/ uint8_t waveform[256]; void GPIO_Setup(){ GPIO_InitTypeDef GPIO_InitStructure; /* Enable DAC and GPIOC clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA, ENABLE); /* Configure PA.04/05 (DAC) as output -------------------------*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); } void Timer_Setup(){ TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); /* TIM2 Configuration */ TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); TIM_TimeBaseStructure.TIM_Period = PERIOD; TIM_TimeBaseStructure.TIM_Prescaler = 0xF; TIM_TimeBaseStructure.TIM_ClockDivision = 0x0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); /* TIM2 TRGO selection */ TIM_SelectOutputTrigger(TIM2, TIM_TRGOSource_OC1Ref); } void DAC_Setup(){ DAC_InitTypeDef DAC_InitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); /* DAC channel1 Configuration */ DAC_InitStructure.DAC_Trigger = DAC_Trigger_None; DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; DAC_Init(DAC_Channel_2, &DAC_InitStructure); /* Enable DAC Channel2: Once the DAC channel2 is enabled, PA.05 is automatically connected to the DAC converter. */ DAC_Cmd(DAC_Channel_2, ENABLE); } void DMA_Setup(){ DMA_InitTypeDef DMA_InitStructure; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); /* DMA 1 Configuration */ DMA_DeInit(DMA1_Channel7); DMA_InitStructure.DMA_PeripheralBaseAddr = DAC_DHR8R1_DACC1DHR; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)waveform; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_BufferSize = 256; 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_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel7, &DMA_InitStructure); DMA_ITConfig(DMA1_Channel7, DMA_IT_HT | DMA_IT_TC | DMA_IT_TE, ENABLE); DMA_Cmd(DMA1_Channel7, ENABLE); } void DMA1_Channel7_IRQHandler(){ LED_On(1); DMA_ClearITPendingBit(DMA1_IT_GL7); } void NVIC_Setup(){ NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel7_IRQn; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_Init(&NVIC_InitStructure); } int main(void){ uint16_t i, x; for (i = 0; i < 256; i++) { if (i < 10) { x = 10; } else if (i < 121) { x = 10 + ((i*i) >> 7); } else if (i < 170) { x = i/2; } else if (i < 246) { x = i + (80 - i/2); } else { x = 10; } waveform[i] = x; } GPIO_Setup(); Timer_Setup(); NVIC_Setup(); DMA_Setup(); DAC_Setup(); LED_Initialize(); while (1) { int i; LED_On(0); //for(i=0; i<4096; i++) // DAC_SetChannel2Data(DAC_Align_12b_R, i); //LED_Off(0); } return(1); }