cancel
Showing results for 
Search instead for 
Did you mean: 

Terrible Experience with STM32 UART HAL

andy2399
Senior
Posted on September 17, 2015 at 23:47

I am having no end of difficulty doing even the simplest thing with serial ports.

I am using STM32CubeMX to generate my project which is being compiled by CrossWorks. I try to send a string of text using:

HAL_UART_Transmit( &huart3, ( uint8_t * )''TEST\r\n'', 6,0 );

All I get out the serial port is T nothing else !

I also wait for incoming characters using:

 if ( HAL_UART_Receive( &huart3, buff, 1, 0 ) == HAL_OK )

but despite typing characters into the terminal application this function never returns HAL_OK.

So I tried enabling interrupts on UART3 and used:

HAL_UART_Transmit_IT( &huart3, ( uint8_t * )''TEST\r\n'', 6 );

Still nothing but if I trace the code through the ISR, it seems to be failing with HAL_BUSY

Does anyone have any idea what I am doing wrong ?

Andy

#free-the-mallocs
6 REPLIES 6
Posted on September 18, 2015 at 02:15

Does anyone have any idea what I am doing wrong ?

We'll be here when you decide it's the HAL

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Barber.Mark
Associate III
Posted on September 18, 2015 at 03:11

Hi Andy,

timeout value needs to be greater than 0. try 200.

HAL_UART_Transmit( &huart3, ( uint8_t * )''TEST\r\n'', 6,200 );

Mark

andy2399
Senior
Posted on September 18, 2015 at 23:42

Mark,

Thanks for your help. I tried as you suggested and got ''TEST'' however, if I change the line to HAL_UART_Transmit( &huart3, ( uint8_t * )''TESTING1234\r\n'', 15,200 ); I only get ''TESTING12'' !

Clive,

Not sure what your comment is supposed to mean !

Are you suggesting that I am wrong thinking the issue is with the HAL ?

Andy

andy2399
Senior
Posted on September 18, 2015 at 23:48

In further testing, I decided to debug the firmware and see what code was returned from HAL_UART_Transmit and so set a breakpoint on the line following Transmit and it never breaks as it gets a hard fault. The stack trace showed the hard fault occured in

UART_WaitOnFlagUntilTimeout.

Andy

andy2399
Senior
Posted on September 20, 2015 at 21:47

Looks like my issue was stack size now my UART transmit and receive appear to be working :)

billmeteor
Associate
Posted on October 02, 2015 at 09:52

Hi Andy,

Can you explain the problem about stack size?

I seem to have the same issue.

Bill