能夠進(jìn)入DMA1_Channel1_IRQHandler,然后就死了。
核心代碼:
void DMA1_Channel1_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void DMA1_Channel1_IRQHandler(void)
{
? ? if(DMA_GetITStatus(DMA1_IT_TC1))
? ? {
? ? ? ? //ControlTask(NULL);
? ? ? ? DMA_ClearITPendingBit(DMA1_IT_TC1);
? ? }
? ? //DMA_ClearFlag(DMA1_FLAG_TC1);
}
void ADC_Config()
{
? ? ADC_InitTypeDef? ADC_InitStructure = {0};
? ? GPIO_InitTypeDef GPIO_InitStructure = {0};
? ? RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
? ? RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
? ? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
? ? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
? ? GPIO_Init(GPIOA, &GPIO_InitStructure);
? ? ADC_DeInit(ADC1);
? ? ADC_CLKConfig(ADC1, ADC_CLK_Div6);
? ? ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
? ? ADC_InitStructure.ADC_ScanConvMode = ENABLE;? ? ? ? ? ? //AAAA,從disable改的
? ? ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
? ? ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
? ? ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
? ? ADC_InitStructure.ADC_NbrOfChannel = PW_ADC_CHANNEL_NO;
? ? ADC_Init(ADC1, &ADC_InitStructure);
? ? ADC_DMACmd(ADC1, ENABLE);
? ? ADC_Cmd(ADC1, ENABLE);
? ? DMA_InitTypeDef DMA_InitStructure = {0};
? ? RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
? ? DMA_DeInit(DMA1_Channel1);
? ? DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&ADC1->RDATAR;
? ? DMA_InitStructure.DMA_MemoryBaseAddr = (u32)power_ADC.channel[0];
? ? DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
? ? DMA_InitStructure.DMA_BufferSize = PW_ADC_CHANNEL_NO;
? ? 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_Normal;
? ? DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
? ? DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;? ? ? ? //AAA
? ? DMA_Init(DMA1_Channel1, &DMA_InitStructure);
? ? NVIC_InitTypeDef NVIC_InitStructure;
? ? DMA_ITConfig(DMA1_Channel1,DMA_IT_TC, ENABLE);? ? ? //使能傳輸完成中斷
? ? NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn;
? ? NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
? ? NVIC_Init(&NVIC_InitStructure);
? ? DMA_Cmd(DMA1_Channel1, ENABLE);
? ? ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_11Cycles);
? ? ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 1, ADC_SampleTime_11Cycles);
? ? ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 1, ADC_SampleTime_11Cycles);
? ? ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 1, ADC_SampleTime_11Cycles);
? ? ADC_SoftwareStartConvCmd(ADC1, ENABLE);
? ? Delay_Ms(50);
? ? ADC_SoftwareStartConvCmd(ADC1, DISABLE);
}