cancel
Showing results for 
Search instead for 
Did you mean: 

what is the purpose of -1 at HAL_UART_Transmit ?"

demir
Senior II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Principal III

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 "Accept as Solution".

View solution in original post

1 REPLY 1
AScha.3
Principal III

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 "Accept as Solution".