完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
void DMA1_Ch4_7_DMAMUX1_OVR_IRQHandler(void){/ USER CODE BEGIN DMA1_Ch4_7_DMAMUX1_OVR_IRQn 0 /
/ USER CODE END DMA1_Ch4_7_DMAMUX1_OVR_IRQn 0 ///HAL_DMA_IRQHandler( hdma_dac1_ch1);HAL_DMA_IRQHandler( hdma_usart1_tx);HAL_DMA_IRQHandler( hdma_adc1);//HAL_DMA_IRQHandler( hdma_usart1_tx); / USER CODE BEGIN DMA1_Ch4_7_DMAMUX1_OVR_IRQn 1 / / USER CODE END DMA1_Ch4_7_DMAMUX1_OVR_IRQn 1 /} else if(uartHandle->Instance==USART1) //USART1-初始化20231211{HAL_RCC_USART1_CLK_ENABLE();HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = Oxy_Tx_Pin;GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;GPIO_InitStruct.Pull = GPIO_NOPULL;GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;GPIO_InitStruct.Alternate = GPIO_AF4_USART1;HAL_GPIO_Init(Oxy_Tx_GPIO_Port, GPIO_InitStruct); GPIO_InitStruct.Pin = Oxy_Rx_Pin;GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;GPIO_InitStruct.Pull = GPIO_NOPULL;GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;GPIO_InitStruct.Alternate = GPIO_AF4_USART1;HAL_GPIO_Init(Oxy_Rx_GPIO_Port, GPIO_InitStruct); hdma_usart1_tx.Instance = DMA1_Channel4; //dma没有初始化-4-6空闲hdma_usart1_tx.Init.Request = DMA_REQUEST_USART1_TX;hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;hdma_usart1_tx.Init.PeriphInc = DMA_PINC_DISABLE;hdma_usart1_tx.Init.MemInc = DMA_MINC_ENABLE;hdma_usart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;hdma_usart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;hdma_usart1_tx.Init.Mode = DMA_CIRCULAR;hdma_usart1_tx.Init.Priority = DMA_PRIORITY_LOW;if (HAL_DMA_Init( hdma_usart1_tx) != HAL_OK){Error_Handler();} __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart1_tx); HAL_NVIC_SetPriority(USART1_IRQn, 3, 0);HAL_NVIC_EnableIRQ(USART1_IRQn);} void MX_USART1_UART_Init(void) //氧浓度20231208{ huart1.Instance = USART1;huart1.Init.BaudRate = 115200;huart1.Init.WordLength = UART_WORDLENGTH_8B;huart1.Init.StopBits = UART_STOPBITS_1;huart1.Init.Parity = UART_PARITY_NONE;huart1.Init.Mode = UART_MODE_TX_RX;huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;huart1.Init.OverSampling = UART_OVERSAMPLING_16;huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;//20230605//huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT;//20230601//huart1.AdvancedInit.OverrunDisable = UART_ADVFEATURE_OVERRUN_DISABLE;//20230601if (HAL_UART_Init( huart1) != HAL_OK){Error_Handler();}if (HAL_UARTEx_SetTxFifoThreshold( huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK){Error_Handler();}if (HAL_UARTEx_SetRxFifoThreshold( huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK){Error_Handler();}if (HAL_UARTEx_DisableFifoMode( huart1) != HAL_OK){Error_Handler();} } |
|
相关推荐
1个回答
|
|
看起来中断处理的结构有点乱,建议还是按照例程来吧。
官方有个例程,直接用参考着用。 STM32Cube_FW_G0_V1.5.0ProjectsSTM32G081B-EVALExamplesUARTUART_TwoBoards_ComDMA |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1786 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1622 浏览 1 评论
1089 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
730 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1680 浏览 2 评论
1942浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
739浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
576浏览 3评论
598浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
560浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 15:41 , Processed in 0.611041 second(s), Total 48, Slave 42 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号