AnsweredAssumed Answered

STM32F4, HAL Lib, USART IRQ

Question asked by crazy_code on Feb 10, 2016
Latest reply on Feb 18, 2016 by Amel N
Hi all,
I'm working with STM32F4 mcu and keil uVision 5 IDE. I'm tryng to configure RS232 periph. but I have a problem. Transmission works fine but I'm not able to receive interrupt when something is received. Here my code:

01./** Init Rs232 port
02.*/
03.void init_RS232(void){
04.    GPIO_InitTypeDef GPIO_InitStruct;
05.     
06.    /* GPIO Ports Clock Enable */
07.    __GPIOC_CLK_ENABLE();
08.    __USART3_CLK_ENABLE();
09.     
10.    /**USART3 GPIO Configuration
11.    PC10     ------> USART2_TX
12.    PC11     ------> USART2_RX
13.  */
14.     
15.    /*Configure GPIO pin : RS232 Pin */
16.  GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11;
17.  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
18.  GPIO_InitStruct.Pull = GPIO_NOPULL;
19.    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
20.    GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
21.  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
22.     
23.    /* Configure USART3 parameters */  
24.    USART3_Handle.Instance = USART3;
25.    USART3_Handle.Init.BaudRate = 9600;
26.    USART3_Handle.Init.Mode = USART_MODE_TX_RX;
27.    USART3_Handle.Init.Parity = USART_PARITY_NONE;
28.    USART3_Handle.Init.StopBits = USART_STOPBITS_1;
29.    USART3_Handle.Init.WordLength = USART_WORDLENGTH_8B;
30.    HAL_USART_Init(&USART3_Handle);
31.     
32.     
33.    HAL_USART_Receive_IT(&USART3_Handle, rx_buffer, 16);   
34.    HAL_NVIC_SetPriority(USART3_IRQn, 3, 0);
35.  HAL_NVIC_EnableIRQ(USART3_IRQn);  
36.}

I would to receive an interrupt every time a char is received and I would like to manage by myself the buffer. With old lib (standard periph lib) I was able to do this. With new HAL ones not.
Can you help me?
Thanks a lot.

Outcomes