2016-02-10 12:40 AM
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:
/** Init Rs232 port
*/
void init_RS232(void){
GPIO_InitTypeDef GPIO_InitStruct;
/* GPIO Ports Clock Enable */
__GPIOC_CLK_ENABLE();
__USART3_CLK_ENABLE();
/**USART3 GPIO Configuration
PC10 ------> USART2_TX
PC11 ------> USART2_RX
*/
/*Configure GPIO pin : RS232 Pin */
GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* Configure USART3 parameters */
USART3_Handle.Instance = USART3;
USART3_Handle.Init.BaudRate = 9600;
USART3_Handle.Init.Mode = USART_MODE_TX_RX;
USART3_Handle.Init.Parity = USART_PARITY_NONE;
USART3_Handle.Init.StopBits = USART_STOPBITS_1;
USART3_Handle.Init.WordLength = USART_WORDLENGTH_8B;
HAL_USART_Init(&USART3_Handle);
HAL_USART_Receive_IT(&USART3_Handle, rx_buffer, 16);
HAL_NVIC_SetPriority(USART3_IRQn, 3, 0);
HAL_NVIC_EnableIRQ(USART3_IRQn);
}
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.
2016-02-18 01:48 AM
Hi crazy_code,
There is no need to callHAL_NVIC_ClearPendingIRQ in the IRQ handler.
-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.