留个记号,我目前调试也碰到一样的问题,不过我的中断使能是在楼主说的位置,但是一样没中断反映,同时看寄存器里的中断标志位也没变化。 /* deinitialize DMA channel2 (USART2 rx) */
dma_deinit(DMA0, DMA_CH2);
dma_init_struct.direction = DMA_PERIPHERAL_TO_MEMORY;
dma_init_struct.memory_addr = (uint32_t)RxBuffer2;
dma_init_struct.memory_inc = DMA_MEMORY_INCREASE_ENABLE;
dma_init_struct.memory_width = DMA_MEMORY_WIDTH_8BIT;
dma_init_struct.number = USART1_Rxbuff_SIZE;
dma_init_struct.periph_addr = USART2_RDATA_ADDRESS;
dma_init_struct.periph_inc = DMA_PERIPH_INCREASE_DISABLE;
dma_init_struct.periph_width = DMA_PERIPHERAL_WIDTH_8BIT;
dma_init_struct.priority = DMA_PRIORITY_ULTRA_HIGH;
dma_interrupt_enable(DMA0, DMA_CH2,DMA_INT_FTF);
dma_init(DMA0, DMA_CH2, &dma_init_struct);
/* configure DMA mode */
dma_circulation_disable(DMA0, DMA_CH2);
dma_interrupt_flag_clear(DMA0,DMA_CH2,DMA_INT_FLAG_G);
/* enable DMA channel2 */
dma_channel_enable(DMA0, DMA_CH2);
void nvic_config(void)
{
nvic_irq_enable(USART0_IRQn, 1,0);
nvic_irq_enable(USART1_IRQn, 0,2);
nvic_irq_enable(USART2_IRQn, 0,1);
nvic_irq_enable(TIMER1_IRQn, 1,0);
nvic_irq_enable(DMA0_Channel2_IRQn, 0,0);
//nvic_irq_enable(DMA0_Channel6_IRQn, 0,0);
}
/* configure USART */
usart_deinit(USART2);
usart_baudrate_set(USART2, 9600U);
usart_parity_config(USART2, USART_PM_NONE);
usart_word_length_set(USART2, USART_WL_8BIT);
usart_stop_bit_set(USART2, USART_STB_1BIT);
usart_receive_config(USART2, USART_RECEIVE_ENABLE);
usart_transmit_config(USART2, USART_TRANSMIT_ENABLE);
usart_dma_receive_config(USART2, USART_RECEIVE_DMA_ENABLE);
usart_dma_transmit_config(USART2,USART_TRANSMIT_DMA_ENABLE );
usart_interrupt_enable(USART2, USART_INT_IDLE);
usart_interrupt_enable(USART2, USART_INT_TC);
usart_enable(USART2);
usart_data_receive(USART2);
int main(void)
{
systick_config();
/* initialize DMA */
Bsp_adc_gpio_config();
Bsp_adc_config();
Bsp_gpio_config();
/* initialize USART */
Bsp_dma_config();
Bsp_usart_config();
Bsp_timer_config();
nvic_config();
|