F460 的DMA串口发送 软件AOS触发不了
#define USART_DMA_UNIT (M4_DMA1)
#define RX_DMA_CH (DmaCh0)
#define RX_DMA_TRG_SEL (EVT_USART1_RI)
#define TX_DMA_CH (DmaCh1)
#define TX_DMA_TRG_SEL (EVT_USART1_TI)
/* DMA block transfer complete interrupt */
#define RX_DMA_BTC_INT_NUM (INT_DMA1_TC0)
#define RX_DMA_BTC_INT_IRQn (Int006_IRQn)
#define TX_DMA_BTC_INT_NUM (INT_DMA1_TC1)
#define TX_DMA_BTC_INT_IRQn (Int005_IRQn)
void dma_tx_init(void)
{
stc_dma_config_t stcDmaInit;
stc_irq_regi_conf_t stcIrqRegiCfg;
/* Enable peripheral clock */
PWC_Fcg0PeriphClockCmd(PWC_FCG0_PERIPH_DMA1 | PWC_FCG0_PERIPH_DMA2,Enable);
/* Enable DMA. */
DMA_Cmd(USART_DMA_UNIT,Enable);
/* Initialize DMA. */
MEM_ZERO_STRUCT(stcDmaInit);
stcDmaInit.u16BlockSize = 10u; /* 1 block */
stcDmaInit.u32SrcAddr = ((uint32_t)(send_buff)); /* Set source address. */
stcDmaInit.u32DesAddr = (uint32_t)(&USART_CH->DR); /* Set destination address. TDR*/
stcDmaInit.stcDmaChCfg.enLlpEn = Disable; /* Disable linked list transfer. */
stcDmaInit.stcDmaChCfg.enSrcInc = AddressIncrease; /* Set source address mode. */
stcDmaInit.stcDmaChCfg.enDesInc = AddressFix; /* Set destination address mode. */
stcDmaInit.stcDmaChCfg.enIntEn = Enable; /* Enable interrupt. */
stcDmaInit.stcDmaChCfg.enTrnWidth = Dma8Bit; /* Set data width 8bit. */
stcDmaInit.u16TransferCnt = 1;
DMA_InitChannel(USART_DMA_UNIT, TX_DMA_CH, &stcDmaInit);
/* Enable the specified DMA channel. */
DMA_ChannelCmd(USART_DMA_UNIT, TX_DMA_CH, Enable);
/* Clear DMA flag. */
DMA_ClearIrqFlag(USART_DMA_UNIT, TX_DMA_CH, TrnCpltIrq);
/* Enable peripheral circuit trigger function. */
PWC_Fcg0PeriphClockCmd(PWC_FCG0_PERIPH_PTDIS,Enable);
/* Set DMA trigger source. */
DMA_SetTriggerSrc(USART_DMA_UNIT, TX_DMA_CH, EVT_AOS_STRG);
/* Set DMA block transfer complete IRQ */
stcIrqRegiCfg.enIRQn = TX_DMA_BTC_INT_IRQn;
stcIrqRegiCfg.pfnCallback = &Dma_TX_IrqCallback;
stcIrqRegiCfg.enIntSrc = TX_DMA_BTC_INT_NUM;
enIrqRegistration(&stcIrqRegiCfg);
NVIC_SetPriority(stcIrqRegiCfg.enIRQn, DDL_IRQ_PRIORITY_DEFAULT);
NVIC_ClearPendingIRQ(stcIrqRegiCfg.enIRQn);
NVIC_EnableIRQ(stcIrqRegiCfg.enIRQn);
AOS_SW_Trigger();
}
以上就是初始化,没法正常输出,有时候会输出一个字节
还想请问下 block是指 的是一次发送数据的量吧,u16TransferCnt 这个是指发送数据的次数 总数据量应该是 block*u16TransferCnt 吧。不知道这里有没有理解错误
|