cancel
Showing results for 
Search instead for 
Did you mean: 

About UART of STM32F030R8 Nucleo board using STM32CubeMX 4.8.0 and keil 5.14.

kufosan
Associate II
Posted on July 08, 2015 at 11:48

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-interrupt
4 REPLIES 4
nesrine
Senior
Posted on July 08, 2015 at 16:05

I suggest you to start from one example of UART from the STM32cubeF0 package/

STM32Cube_FW_F0_V1.3.0\Projects\STM32F030R8-Nucleo\Examples\UART

Syrine

kufosan
Associate II
Posted on July 09, 2015 at 05:27

Thanks your reply

but I have tested using that sample program, the error was occurred.

So I checked the usb2serial module and test serial program also, these are ok.

and I have two STM32F030R8 Nucleo board, two boards are same results.

at last I tested by another method.

the result is interesting. if the size of the received data is 90Byte,

(012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789) 

then HAL_UART_RxCpltCallback gets signal but just one time.

Maybe I think treating the receive buffer size or some flag setting is needed.

 

but sample program has not about that.

My settings by STM32CubeMX are like below,

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?

kufosan
Associate II
Posted on July 11, 2015 at 01:59

Doesn't anybody know about this problem or this solution?

Would you help me?

Posted on July 11, 2015 at 02:20

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.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..