2016-02-07 01:52 PM
Hello guys,
I 'm a new STM32 user that started using and learning STM32 MCUs developing .I have circuit that I have a usart connection at usart2.I can transmit data from MCU perfectly and also I can receive data easily but after a few receiving data from the usart , my receive interrupt doesn't run. In addition , my project generated by STMCUBEMx.my code is :''void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){__HAL_UART_FLUSH_DRREGISTER(&huart2);HAL_UART_Transmit(&huart2,(_8bit_var*)'' interrupt 1 '',sizeof('' interrupt 1 ''),100);HAL_UART_Receive_IT(&huart2,data,5);}int main(void){ /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ HAL_UART_Receive_IT(&huart2,data,5); //int cun = 0;HAL_GPIO_WritePin(BT_KEY_GPIO_Port,BT_KEY_Pin,GPIO_PIN_RESET);HAL_GPIO_WritePin(LED3_GPIO_Port,LED3_Pin,GPIO_PIN_SET);HAL_GPIO_WritePin(LED4_GPIO_Port,LED4_Pin,GPIO_PIN_SET);HAL_Delay(500); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { HAL_GPIO_TogglePin(LED3_GPIO_Port,LED3_Pin); delay_ms(100); //works exactly like HAL_Delay(); HAL_GPIO_TogglePin(LED4_GPIO_Port,LED4_Pin); delay_ms(100); HAL_UART_Transmit(&huart2,data,5,100); delay_ms(20); int cu; for (cu = 0;cu <5;cu++) { data[cu] = 0; }} /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */if (HAL_GPIO_ReadPin(S4_GPIO_Port,S4_Pin)==GPIO_PIN_RESET) { HAL_GPIO_WritePin(BT_KEY_GPIO_Port,BT_KEY_Pin,GPIO_PIN_SET); HAL_UART_Transmit(&huart2,(_8bit_var*)'' mydata '',sizeof('' mydata ''),100); }else{ HAL_UART_Transmit(&huart2,(_8bit_var*)'' our data '',sizeof('' our data ''),100);} } /* USER CODE END 3 */}'' #stm32f103 #uart #stm32f103 #stm32 #no-hablo-hal #usart2016-02-07 05:52 PM
And is there an IRQHandler calling into the HAL?
2016-02-08 02:29 AM
I know it's some thing related to an interrupt but I don't now what exactly it do?
2016-02-14 09:12 AM
who can answer me?
is there s.b that can do me a favor and solve my problem
?!?2016-02-14 09:47 AM
Perhaps you can review the example directories provided with Cube?
You'd presumably have some of the initialization code enable the NVIC, and then your stm32f1xx_it.c file would need to have a handler to call back into the HAL library to do the callback/dispatch.void USART2_IRQHandler(void)
{
HAL_UART_IRQHandler(&husart2);
}
2016-02-14 11:23 AM
Thank you Clive1.
I mix up each time I check up the examples included in cube.the uart examples even didn't used HAL_UART_RECIVEIT().it has some thing like BSD led ...? which is not understandable for me.2016-02-14 12:18 PM
CubeMX\STM32Cube_FW_F1_V1.2.0\Projects\STM32VL-Discovery\Examples\UART\UART_TwoBoards_ComIT\Src\main.c
BSD LED? Blue Screen of Death?