DMA 每次只能接收256字节的问题

2019-10-15 03:57发布

PC机串口助手向芯片发数据,DMA每次中断只能接收256字节,发送字节如为260字节,就会两次进入中断,第一次接受256字节,第二次接受剩下的4字节改变DMA_BufferSize的值也没有用[mw_shl_code=applescript,true]/* DMA1 Channel5 (triggered by USART1 Rx event) Config */
        DMA_DeInit(DMA2_Stream5);
        DMA_InitStructure.DMA_Channel = DMA_Channel_4;
        DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)(&USART1->DR);
        DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)USART1_RECEIVE_DATA;
        DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
        DMA_InitStructure.DMA_BufferSize = UART_RX_LEN;  
        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_Circular;
        DMA_InitStructure.DMA_Priority = DMA_Priority_High;
       
        DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable;//2»¿afifo
        DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
        DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
        DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
       
        DMA_Init(DMA2_Stream5, &DMA_InitStructure);  
        DMA_ITConfig(DMA2_Stream5, DMA_IT_TC, ENABLE);
        DMA_ITConfig(DMA2_Stream5, DMA_IT_TE, ENABLE);

        /* Enable USART1 DMA RX request */
        USART_DMACmd(USART1, USART_DMAReq_Rx, ENABLE);
        DMA_Cmd(DMA2_Stream5, ENABLE); [/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。