GPIOA.0作为规则通道,GPIOA.1做注入通道,用GPIO.15按键触发注入通道转换。总是进不了中断,总是停在启动文件 B. ENDP ALIGN 的地方。 问一下引脚15是不是那么配置? 小弟新手望各神解答啊。GPIOA.0上的ADC转换和DMA是没有问题的。
void RCC_Configuration(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 , ENABLE);
RCC_ADCCLKConfig(RCC_PCLK2_Div8);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/*Disable JTAG DEbug*/
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE);
/*Config InitStructure*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/*Set Key Init*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
void ADC1_Configuration(void)
{
/* Initialize the ADC1 according to the ADC_InitStructure members */
ADC_InitTypeDef ADC_InitStructure;
/*Fill ADC InitStrcuture*/
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1; /*Number of Channel of Regular Channels*/
ADC_Init(ADC1, &ADC_InitStructure);
/*Regular Group*/
ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1,ADC_SampleTime_7Cycles5);
/*Injected Group*/
ADC_InjectedSequencerLengthConfig(ADC1, 1);
ADC_InjectedChannelConfig(ADC1, ADC_Channel_1, 2,ADC_SampleTime_7Cycles5);
ADC_ExternalTrigInjectedConvConfig(ADC1,ADC_ExternalTrigInjecConv_Ext_IT15_TIM8_CC4);
ADC_ExternalTrigInjectedConvCmd(ADC1, ENABLE);
ADC_AutoInjectedConvCmd(ADC1, DISABLE);
/*Config INTERRUPT of ADC1*/
ADC_ITConfig(ADC1, ADC_IT_JEOC , ENABLE);
/*ENABLE DMA of ADC*/
ADC_DMACmd(ADC1, ENABLE);
/*ENABLE PERIPH ADC1*/
ADC_Cmd(ADC1, ENABLE);
/*Calibration of ADC*/
ADC_ResetCalibration(ADC1);
while( ADC_GetResetCalibrationStatus(ADC1)==SET)
{
}
ADC_StartCalibration(ADC1);
while(ADC_GetCalibrationStatus(ADC1)==SET)
{
}
/*End Calibration of ADC*/
/*Start ADC Converting*/
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
}
void DMA_Configuration(void)
{
DMA_InitTypeDef DMA_InitStructure;
/*Config DMA*/
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&(ADC1->DR);//ADC1_BASE + 0x4c;
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_Value;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
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_Medium;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
/*ENABLE DMA*/
DMA_Cmd(DMA1_Channel1, ENABLE);
}
void EXTI_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource15);
EXTI_InitStructure.EXTI_Line = EXTI_Line15;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Event;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
/* Configure the Priority Grouping with 1 bit */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
/* Enable TIM3 global interrupt with Preemption Priority 0 and Sub
Priority as 2 */
NVIC_InitStructure.NVIC_IRQChannel = ADC1_2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
此帖出自
小平头技术问答
一周热门 更多>