UART Transmitting issue or any other issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-16 5:58 AM - last edited on ‎2024-09-16 8:20 AM by mƎALLEm
Hi Everyone,
I am using STM32F407DISCO board and made a simple program which transmit some values. The program is as follows
#include "stm32f4xx_hal.h"
#include "main.h"
UART_HandleTypeDef USART2Config;
void GPIO_Init(void);
void UART2_Init(void);
void Err_Handle(void);
char data[] = "Hello";
uint8_t value = 43;
uint16_t value2 = 1024;
char buffer[10];
int main(){
HAL_Init();
GPIO_Init();
UART2_Init();
HAL_GPIO_WritePin(GPIOD, RED_LED, 1);
HAL_GPIO_WritePin(GPIOD, GREEN_LED, 1);
HAL_GPIO_WritePin(GPIOD, ORANGE_LED, 1);
HAL_GPIO_WritePin(GPIOD, BLUE_LED, 1);
HAL_UART_Transmit(&USART2Config, (uint8_t*) data, strlen (data), HAL_MAX_DELAY);
HAL_UART_Transmit(&USART2Config, &value, 1, HAL_MAX_DELAY);
HAL_UART_Transmit(&USART2Config, (uint8_t*) &value2, sizeof(value2), HAL_MAX_DELAY);
while(1){
}
}
The code above only Transmit line 28 and 29, Line 30 not transmitted.
but when I comment out Line 28 then line 29 and 30 transmitted.
What I am doing wrong here?
Following is the logic analyzer waveform when Line no 28,29 and 30 are transmitted.
Following is the logic analyzer waveform when Line no 29 and 30 are transmitted
Kindly correct me where I am making mistake.
Thanks and best regards
Solved! Go to Solution.
- Labels:
-
STM32F4 Series
-
UART-USART
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-17 10:04 PM
The issue is resolved after I added the following function
void SysTick_Handler(void){
HAL_IncTick();
HAL_SYSTICK_IRQHandler();
}
Thanks everyone for your support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-16 6:28 AM
Is there any error or warning during compilation?
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-16 6:45 AM
If you single-step those lines, does each one transmit?
Do any of the HAL_UART_Transmit() calls return an error?
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-16 7:30 AM
@waclawek.jan No there is no error or warning while compilation
@Andrew Neil No I didn't check the single-step nor I checked if any error is returning.
How do I check if it is returning any error or not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-16 7:40 AM
@AHayee wrote:How do I check if it is returning any error or not?
The same way you'd check the return value from any function call:
HAL_StatusTypeDef result;
:
:
result = HAL_UART_Transmit( &USART2Config, (uint8_t*) data, strlen (data), HAL_MAX_DELAY );
if( result != HAL_OK )
{
// An error occured!
}
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-16 8:06 AM - edited ‎2024-09-16 8:07 AM
@AHayee wrote:I am using STM32F407DISCO board
How are you connecting to the UART?
This board requires you to make the connection manually from the UART to the ST-Link's VCP:
Are you sure that your connections are secure & reliable?
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-16 8:10 AM
Try to transmit something also in the while() loop, e.g. the "Hello" string, in a loop.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-16 3:12 PM
Looks like you're re-inventing the wheel
UART_HandleTypeDef USART2Config;
Show your configuration.
And where is you System Clock configuration? Are you relying on HSI?
What is APB1 set as?
Better yet, upload your IOC file.
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-17 10:04 PM
The issue is resolved after I added the following function
void SysTick_Handler(void){
HAL_IncTick();
HAL_SYSTICK_IRQHandler();
}
Thanks everyone for your support
