我用ADC采集三路电压,然后用DMA传输,但是我对DMA传输一半和传输完成设置了中断,但是似乎并没有进入到中断函数中,以下是我的程序,大神们请看看哪里出错了?
NVIC_InitTypeDef NVIC_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); //ê1ÄüDMA′«êä
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn; //
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =1; //
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //
NVIC_Init(&NVIC_InitStructure);
DMA_DeInit(DMA1_Channel1); //½«DMAμÄí¨μà1¼Ä′æÆ÷ÖØéèÎaè±ê¡Öμ
//DMA1_MEM_LEN=cndtr;
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&ADC1->DR; //DMAíaéè»ùμØÖ·
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)AD_Value; //DMAÄú′æ»ùμØÖ·
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; //êy¾Y′«êä·½Ïò£¬′óÄú′æ¶áè¡·¢Ëíμ½íaéè
DMA_InitStructure.DMA_BufferSize = M*N; //DMAí¨μàμÄDMA»o′æμÄ′óD¡
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //íaéèμØÖ·¼Ä′æÆ÷2»±ä
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //Äú′æμØÖ·¼Ä′æÆ÷μYÔö
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; //êy¾Y¿í¶èÎa8λ
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word; //êy¾Y¿í¶èÎa8λ
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //1¤×÷ÔúÕy3£Ä£ê½
DMA_InitStructure.DMA_Priority = DMA_Priority_High; //DMAí¨μà xóμóDÖDóÅÏ輶
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //DMAí¨μàxûóDéèÖÃÎaÄú′æμ½Äú′æ′«êä
DMA_Init(DMA1_Channel1, &DMA_InitStructure); //¸ù¾YDMA_InitStructÖDÖ¸¶¨μÄ2Îêy3õê¼»ˉDMAμÄí¨μàUSART1_Tx_DMA_ChannelËù±êê¶μļÄ′æÆ÷
DMA_ITConfig(DMA1_Channel1, DMA_IT_HT,ENABLE);//′«êä1y°ë
DMA_ITConfig(DMA1_Channel1, DMA_IT_TC,ENABLE);//′«êäíê3éÖD¶Ï
DMA_Cmd(DMA1_Channel1, ENABLE);
以上是我的DMA设置,
void DMA1_Channel1_IRQHandler(void)
{
if(DMA_GetITStatus(DMA1_IT_HT1)!=RESET)
{
DMA_ClearITPendingBit(DMA1_IT_HT1);//′«êäò»°ë
DMA_ClearFlag(DMA1_FLAG_HT1);
flag=1;
}
if(DMA_GetITStatus(DMA1_IT_TC1)!=RESET)
{
DMA_ClearITPendingBit(DMA1_IT_TC1);//′«êäíê3é±êÖ¾
DMA_ClearFlag(DMA1_FLAG_TC1);
flag=2;
}
}
这是我的中断函数,设置在STM32f10x_it.c.,然后adc我也都设置好了,但是这个flag似乎一直不变为1,我设置是传输到一半就变为1 啊 |