各位,我的DMA配置如下:
ch = HAL_DMA_GET_DESC1234( HAL_DMA_CH_RX );
// Abort any pending DMA operations (in case of a soft reset).
HAL_DMA_ABORT_CH( HAL_DMA_CH_RX );
// The start address of the source.
HAL_DMA_SET_SOURCE( ch, DMA_UxDBUF );
// Using the length field to determine how many bytes to transfer.
HAL_DMA_SET_VLEN( ch, HAL_DMA_VLEN_1_P_VALOFFIRST );//第一个字节作为接收长度,长度字节不计入接收计数
/* The trick is to cfg DMA to xfer 2 bytes for every 1 byte of Rx.
* The byte after the Rx Data Buffer is the Baud Cfg Register,
* which always has a known value. So init Rx buffer to inverse of that
* known value. DMA word xfer will flip the bytes, so every valid Rx byte
* in the Rx buffer will be preceded by a DMA_PAD char equal to the
* Baud Cfg Register value.
*/
HAL_DMA_SET_WORD_SIZE( ch, HAL_DMA_WORDSIZE_BYTE );//按照字节接收
// The bytes are transferred 1-by-1 on Rx Complete trigger.
HAL_DMA_SET_TRIG_MODE( ch, HAL_DMA_TMODE_BLOCK );//块传输
HAL_DMA_SET_TRIG_SRC( ch, DMATRIG_RX );
// The source address is constant – the Rx Data Buffer.
HAL_DMA_SET_SRC_INC( ch, HAL_DMA_SRCINC_0 );
// The destination address is incremented by 1 word after each transfer.
HAL_DMA_SET_DST_INC( ch, HAL_DMA_DSTINC_1 );
HAL_DMA_SET_DEST( ch, dmaCfg.rxBuf );//tempbuf
//
HAL_DMA_SET_LEN( ch, HAL_UART_DMA_RX_MAX );//这个我设置为160
// The DMA is to be polled and shall not issue an IRQ upon completion.
HAL_DMA_SET_IRQ( ch, HAL_DMA_IRQMASK_ENABLE );//HAL_DMA_IRQMASK_DISABLE//HAL_DMA_IRQMASK_ENABLE
DMAIE =1;
// Xfer all 8 bits of a byte xfer.
HAL_DMA_SET_M8( ch, HAL_DMA_M8_USE_8_BITS );
// DMA has highest priority for memory access.
HAL_DMA_SET_PRIORITY( ch, HAL_DMA_PRI_HIGH);
从另外一台机器发送字节0B +11个字节
DMA发生接收中断,收到12个字节的0B,请问是怎么回事,DMA块中断应该怎么应用?
lianghui xie:
帮忙顶一下,求解!!!