问答

汇集网友智慧,解决技术难题

h32446975

TA的家园币:95  

  • F460 DMA串口发送 软件AOS触发问题

    #defineUSART_DMA_UNIT(M4_DMA1)#defineRX_DMA_CH(DmaCh0)#defineRX_DMA_TRG_SEL(EVT_USART1_RI)#defineTX_DMA_CH(DmaCh1)#defineTX_DMA_TRG_SEL(EVT_USART1_TI)/*DMAblocktransfercompleteinterrupt*/#defineRX_DMA_BTC_INT_NUM(INT_DMA1_TC0)#defineRX_DMA_BTC_INT_IRQn(Int006_IRQn)#defineTX_DMA_BTC_INT_NUM(INT_DMA1_TC1)#defineTX_DMA_BTC_INT_IRQn(Int005_IRQn)voiddma_tx_init(void){stc_dma_config_tstcDmaInit;stc_irq_regi_conf_tstcIrqRegiCfg;/*Enableperipheralclock*/PWC_Fcg0PeriphClockCmd(PWC_FCG0_PERIPH_DMA1|PWC_FCG0_PERIPH_DMA2,Enable);/*EnableDMA.*/DMA_Cmd(USART_DMA_UNIT,Enable);/*InitializeDMA.*/MEM_ZERO_STRUCT(stcDmaInit);stcDmaInit.u16BlockSize=10u;/*1block*/stcDmaInit.u32SrcAddr=((uint32_t)(send_buff));/*Setsourceaddress.*/stcDmaInit.u32DesAddr=(uint32_t)(&USART_CH->DR);/*Setdestinationaddress.TDR*/stcDmaInit.stcDmaChCfg.enLlpEn=Disable;/*Disablelinkedlisttransfer.*/stcDmaInit.stcDmaChCfg.enSrcInc=AddressIncrease;/*Setsourceaddressmode.*/stcDmaInit.stcDmaChCfg.enDesInc=AddressFix;/*Setdestinationaddressmode.*/stcDmaInit.stcDmaChCfg.enIntEn=Enable;/*Enableinterrupt.*/stcDmaInit.stcDmaChCfg.enTrnWidth=Dma8Bit;/*Setdatawidth8bit.*/stcDmaInit.u16TransferCnt=1;DMA_InitChannel(USART_DMA_UNIT,TX_DMA_CH,&stcDmaInit);/*EnablethespecifiedDMAchannel.*/DMA_ChannelCmd(USART_DMA_UNIT,TX_DMA_CH,Enable);/*ClearDMAflag.*/DMA_ClearIrqFlag(USART_DMA_UNIT,TX_DMA_CH,TrnCpltIrq);/*Enableperipheralcircuittriggerfunction.*/PWC_Fcg0PeriphClockCmd(PWC_FCG0_PERIPH_PTDIS,Enable);/*SetDMAtriggersource.*/DMA_SetTriggerSrc(USART_DMA_UNIT,TX_DMA_CH,EVT_AOS_STRG);/*SetDMAblocktransfercompleteIRQ*/stcIrqRegiCfg.enIRQn=TX