基础实验9-DMA实验
实验目的:
掌握DMA的使用方法。
实验现象:
下载程序,PC端打开串口助手,选择USB线的端口,波特率为115200,无校验,停止位为1位,HEX模式接收。系统自动将源缓冲区中的内容传送到目标缓冲区,并将目标缓冲区中的内容通过串口输出。
文章目录
实验代码
int main(void)
{
/* USER CODE BEGIN 1 */
int8_t index = 0;
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
HAL_DMA_Start(&hdma_memtomem_dma1_channel1, (uint32_t)Source_Data, (uint32_t)Destination_Data, 20);
HAL_UART_Transmit(&huart2,Destination_Data,20,100);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}