2015-07-08 02:48 AM
Dear
I have tested the STM32F030R8 Nucleo board using STM32CubeMX 4.8.0 and keil 5.14. serial setting :/* USART1 init function */
void MX_USART1_UART_Init(void) {huart1.Instance = USART1;
huart1.Init.BaudRate = 38400; 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_8; huart1.Init.OneBitSampling = UART_ONEBIT_SAMPLING_DISABLED ; huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; HAL_UART_Init(&huart1);}
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{GPIO_InitTypeDef GPIO_InitStruct;
if(huart->Instance==USART1) { /* USER CODE BEGIN USART1_MspInit 0 *//* USER CODE END USART1_MspInit 0 */
/* Peripheral clock enable */ __USART1_CLK_ENABLE(); /**USART1 GPIO Configuration PA9 ------> USART1_TX PA10 ------> USART1_RX */ GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF1_USART1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);/* Peripheral interrupt init*/
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USART1_IRQn); /* USER CODE BEGIN USART1_MspInit 1 *//* USER CODE END USART1_MspInit 1 */
} when UART using HAL_UART_Transmit_IT(HAL_UART_TxCpltCallback) is good. but HAL_UART_Receive_IT(HAL_UART_RxCpltCallback) is not good. HAL_UART_RxCpltCallback did not happen any signal.. What is the problem? and How can I use the IRQhandler() ? if I want to treat receiving data in IRQhandler(), How can both TX and RX treat ?void USART1_IRQHandler(void)
{ /* USER CODE BEGIN USART1_IRQn 0 *//* USER CODE END USART1_IRQn 0 */
HAL_UART_IRQHandler(&huart1); /* USER CODE BEGIN USART1_IRQn 1 *//* USER CODE END USART1_IRQn 1 */
} Would you help me? #stm32-serial-interrupt2015-07-08 07:05 AM
I suggest you to start from one example of UART from the STM32cubeF0 package/
STM32Cube_FW_F0_V1.3.0\Projects\STM32F030R8-Nucleo\Examples\UARTSyrine2015-07-08 08:27 PM
serial setting :
/* USART1 init function */
void MX_USART1_UART_Init(void) {huart1.Instance = USART1;
huart1.Init.BaudRate = 38400; 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_8; huart1.Init.OneBitSampling = UART_ONEBIT_SAMPLING_DISABLED ; huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; HAL_UART_Init(&huart1);}
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{GPIO_InitTypeDef GPIO_InitStruct;
if(huart->Instance==USART1) { /* USER CODE BEGIN USART1_MspInit 0 *//* USER CODE END USART1_MspInit 0 */
/* Peripheral clock enable */ __USART1_CLK_ENABLE(); /**USART1 GPIO Configuration PA9 ------> USART1_TX PA10 ------> USART1_RX */ GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF1_USART1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);/* Peripheral interrupt init*/
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USART1_IRQn); /* USER CODE BEGIN USART1_MspInit 1 *//* USER CODE END USART1_MspInit 1 */
} Would you help me?2015-07-10 04:59 PM
2015-07-10 05:20 PM
Doesn't anybody know about this problem or this solution? Would you help me?
Apparently not, this is how forums work, there aren't always people with answers. I guess you'll either need to be patient, or look elsewhere for answers.