UART2 VCP L432KC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-23 08:21 PM
while (1)
{
/* USER CODE END WHILE */
if (HAL_UART_Receive(&huart2, data, 10, 100) == HAL_OK) {
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 1);
HAL_Delay(200);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 0);
HAL_Delay(200);
}
/* USER CODE BEGIN 3 */
}
This is my code to check if I am sending any data from Putty/Realterm/Docklight to UART2 and then blinking the in built LED. What are some reasons this might not be working? I tried this in interrupt mode as well.
- Labels:
-
STM32L4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-24 04:29 PM
Hello @Abijith
This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.
Regards,
Roger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-24 04:58 PM
Can't we please just have FAE's, or whomever, just come and answer simple questions directly?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-24 05:15 PM - edited ‎2024-06-24 05:21 PM
Well it's going to repeatedly fail if you don't get 10 characters in 100 ms, like you pressing continuously.
Then slacking off for 400 ms when no reception can occur and you'll get overrun or other errors due to inattention.
You'd do better with a simple echo back
while(1)
{
if ((USART2->ISR & USART_ISR_RXNE) == 0) // Wait for Char
{
if (USART2->ISR & USART_ISR_ORE) // Overrun Error
USART2->ICR = USART_ICR_ORECF;
if (USART2->ISR & USART_ISR_NE) // Noise Err
USART2->ICR = USART_ICR_NCF;
if (USART2->ISR & USART_ISR_FE) // Framing Error
USART2->ICR = USART_ICR_FECF;
}
else // RXNE
USART2->TDR = USART2->RDR; // Read Char, Echo
}
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-24 05:24 PM - edited ‎2024-06-24 05:24 PM
@Abijith The timeout 100 ms is probably too short. Try something like 10000 ms (10s) or indefinite.