Skip to main content
Senior
February 18, 2024
Solved

what is the purpose of -1 at HAL_UART_Transmit ?"

Hi,

I copied below code from internet which works perfect while using HAL_UART_Transmit. However, I want to understand more why there is minus 1 (-1) at timeout parameter ?

P.S.: This question may not be directed at the right section, apologies for that.

 

demir_0-1708271235831.png

Please feel free to direct me on the right section. Thanks.

This topic has been closed for replies.
AScha.3
AScha.3Best answer
Super User
February 18, 2024

Hi,

this is what "real" C programmers like so much: writing some mystery...

-1 as INT32  is 0xFFFFFFFF  , what should give a warning here, because timeout is uint32_t , 

the nice-to-read define would be :   HAL_MAX_DELAY  . ( 0xFFFFFFFFU )

btw

I would set a more useful/realistic timeout, say 100ms ; HAL_MAX_DELAY would wait 49 days...

If you feel a post has answered your question, please click on " Best Answer ".

1 reply

AScha.3
AScha.3Best answer
Super User
February 18, 2024

Hi,

this is what "real" C programmers like so much: writing some mystery...

-1 as INT32  is 0xFFFFFFFF  , what should give a warning here, because timeout is uint32_t , 

the nice-to-read define would be :   HAL_MAX_DELAY  . ( 0xFFFFFFFFU )

btw

I would set a more useful/realistic timeout, say 100ms ; HAL_MAX_DELAY would wait 49 days...

If you feel a post has answered your question, please click on " Best Answer ".