char buf[128] = "start";
hdma_usart1_tx.Instance->CCR &= ~(1 << 0);//Bit 0 EN: Channel enable 关闭通道
hdma_usart1_tx.Instance->CNDTR = 5;//DMA1,传输数据量
hdma_usart1_tx.Instance->CPAR = (uint32_t)&huart1.Instance->DR;
hdma_usart1_tx.Instance->CMAR = (uint32_t)&buf;//传送数据的地址的地址
hdma_usart1_tx.Instance->CCR |= 1 << 0;//Bit 0 EN: Channel enable 开启通道
USART1->CR3 = 1 << 7; //Bit 7 DMAT: DMA enable transmitter
while(1)
{
/*
* DMA interrupt status register (DMA_ISR)
* Bits 25, 21, 17, 13,9, 5, 1
TCIFx: Channel x transfer complete flag (x = 1 ..7)
This bit is set by hardware. It is cleared by software writing 1 to the corresponding
bit in the DMA_IFCR register.
*/
/*
* DMA interrupt flag clear register (DMA_IFCR)
* Bits 25, 21, 17, 13,9, 5, 1
* CTCIFx: Channel x transfer complete clear (x = 1 ..7)
* This bit is set and cleared by software.
* 0: No effect
* 1: Clears the corresponding TCIF flag in the DMA_ISR register
*/
if (hdma_usart1_tx.DmaBaseAddress->ISR & (1 << 13)) //等待传输完成
{
hdma_usart1_tx.DmaBaseAddress->IFCR |= 1 << 13; //清除中断
break;
}
huart3.Instance->DR = hdma_usart1_tx.Instance->CNDTR;
}
DMA串口传送_寄存器
最新推荐文章于 2024-10-03 22:11:26 发布