使用usart2, 对应的DMA中断是RX_DMA DMA1_CHN6,TX_DMA DMA1_CHN7 现在的问题是,数据的收发都是可以的,通过DMA的BUF和电脑的串口调试工具连接,能够正常收发。 但是,始终无法进去中断处理函数(DMA1_Channel6_IRQHandler, DMA1_Channel7_IRQHandler)。 求高手指点,我现在用的库是V3.5???? 附主要代码: //-----------初始化 UsartApiConfigRCC(); UsartApiConfigNVIC(); UsartApiConfigGPIO(); UsartApiConfigDMA(); UsartApiConfigInit(); /* Enable USARTy DMA TX request */ USART_DMACmd(USARTz, USART_DMAReq_Tx, ENABLE); /* Enable USARTz DMA TX request */ USART_DMACmd(USARTz, USART_DMAReq_Rx, ENABLE); /* Enable USARTy */ USART_Cmd(USARTz, ENABLE); /* Enable USARTy DMA TX Channel */ DMA_Cmd(DMA_CHN_RX, ENABLE); static void UsartApiConfigNVIC() { NVIC_InitTypeDef NVIC_InitStructure; /* Configure the NVIC Preemption Priority Bits */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); /* Enable the USARTy Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = USARTy_IRQn; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* Enable the USARTz Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = USARTz_IRQn; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel6_IRQn; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel7_IRQn; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } static void UsartApiConfigDMA() { DMA_InitTypeDef DMA_InitStructure; //DMA_InitTypeDef DMA_InitStructure; /* USARTz_Tx_DMA_Channel (triggered by USARTz Tx event) Config */ DMA_DeInit(DMA_CHN_RX); DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&USARTz->DR;//USARTz_DR_Base; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)g_sDmaRxBuf; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;//接受方向 DMA_InitStructure.DMA_BufferSize = sizeof(g_sDmaRxBuf); 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_Normal; DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA_CHN_RX, &DMA_InitStructure); DMA_ITConfig(DMA_CHN_RX, DMA_IT_TC, ENABLE); } //-------------中断函数 void DMA1_Channel6_IRQHandler(void)// DMA Rx Interrupt (Usart2) { STM_EVAL_LEDToggle(LED2); } void DMA1_Channel7_IRQHandler(void)// DMA Tx Interrupt (Usart2) { g_iUsartSendFlag = E_FLAG_OFF; DMA_Cmd(DMA_CHN_TX, DISABLE); UsartJudgeDataToSend(); } //----------STARTup DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 |
回复:stm32 Usart DMA中断,无法进去DMA中断函数,求解???
回复:stm32 Usart DMA中断,无法进去DMA中断函数,求解???
DMA_Interrupt.rar
2012-11-9 16:00 上传
点击文件名下载附件
15.31 KB, 下载次数: 582
RE:stm32 Usart DMA中断,无法进去DMA中断函数,求解?? 【悬赏问答】
RE:stm32 Usart DMA中断,无法进去DMA中断函数,求解?? 【悬赏问答】
回复:stm32 Usart DMA中断,无法进去DMA中断函数,求解?? 【悬赏问答】
怎么会进中断呢 楼主 要配置 下面 这个函数 就会进中断了
void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
assert_param(IS_DMA_CONFIG_IT(DMA_IT));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
/* Enable the selected DMA interrupts */
DMAy_Channelx->CCR |= DMA_IT;
}
else
{
/* Disable the selected DMA interrupts */
DMAy_Channelx->CCR &= ~DMA_IT;
}
}
回复:stm32 Usart DMA中断,无法进去DMA中断函数,求解?? 【悬赏问答】
我刚才测试官方例程是可以的,你可以参考一下:
!~~~~
回复:stm32 Usart DMA中断,无法进去DMA中断函数,求解?? 【悬赏问答】
我刚才测试官方例程是可以的,你可以参考一下:
&************