Skip to main content
AMP HF
Associate II
February 27, 2018
Question

The__HANDLE__ para in the functions, how to call

  • February 27, 2018
  • 1 reply
  • 740 views
Posted on February 27, 2018 at 04:11

When I use this function __HAL_TIM_SET_COMPARE(__HANDLE__, __CHANNEL__, __COMPARE__) like this:

__HAL_TIM_SET_COMPARE(&htim3,TIM_CHANNEL_2,10);

//I should use the '&' with the handle para.

what will happen if I use it like 

__HAL_TIM_SET_COMPARE(htim3,TIM_CHANNEL_2,10) without '&'?

But when I use IWDG funtion __HAL_IWDG_RELOAD_COUNTER(__HANDLE__):

__HAL_IWDG_RELOAD_COUNTER(hiwdg);

//why no '&' here?

#stm32f0-hal #__handle__ #stm32
This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
February 27, 2018
Posted on February 27, 2018 at 05:03

You want to pass it as an address, so typically it would have and &

You're second case is where it is already an address (pointer) like inside 

HAL_IWDG_Init().

HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg)

{

...

/* Reload IWDG counter with value defined in the reload register */

__HAL_IWDG_RELOAD_COUNTER(hiwdg);

..

}

vs top level stuff

static IWDG_HandleTypeDef IwdgHandle; // ACTUAL PHYSICAL STRUCTURE

..

/*##-3- Configure & Start the IWDG peripheral #########################################*/

/* Set counter reload value to obtain 1 sec. IWDG TimeOut.

IWDG counter clock Frequency = uwLsiFreq

Set Prescaler to 32 (IWDG_PRESCALER_32)

Timeout Period = (Reload Counter Value * 32) / uwLsiFreq

So Set Reload Counter Value = (1 * uwLsiFreq) / 32 */

IwdgHandle.Instance = IWDG;

IwdgHandle.Init.Prescaler = IWDG_PRESCALER_32;

IwdgHandle.Init.Reload = (uwLsiFreq / 32);

IwdgHandle.Init.Window = IWDG_WINDOW_DISABLE;

if(HAL_IWDG_Init(&IwdgHandle) != HAL_OK) // ADDRESS OF STRUCTURE

{

/* Initialization Error */

Error_Handler();

}

This would seem to be basic C pointer stuff.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..