cancel
Showing results for 
Search instead for 
Did you mean: 

Pull Up pin

bruno2
Associate
Posted on May 26, 2014 at 20:55

Is there some way to turn off a pull up input for some time and later turn it on on a certain frequency? 

The pull up pin drain too much current.
3 REPLIES 3
abbas
Associate II
Posted on May 27, 2014 at 09:15

you can use a timer interrupt handler to turn pull up on and off at a certain frequency

bruno2
Associate
Posted on May 27, 2014 at 12:55

How can i do that? Can you send me an axample?

abbas
Associate II
Posted on May 27, 2014 at 14:10

for example, you config one of your timers like this

void TIM1_Config(void)

{

  TIM1_DeInit ();

  TIM1_TimeBaseInit (TIM1_PRESCALER, TIM1_COUNTERMODE_UP, TIM1_PERIOD, 0);

  TIM1_ITConfig (TIM1_IT_UPDATE, ENABLE);

  TIM1_ARRPreloadConfig (ENABLE);

  TIM1_Cmd (ENABLE);

}

and in interrupt handler you can do like this, flag_pull_up must be defined as a global variable

INTERRUPT_HANDLER (TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)

{

  if (flag_GPIO_pull_up)

  {

    GPIO_Init  ( GPIOx,  GPIO_Pin, GPIO_MODE_IN_FL_NO_IT );

  }

  else 

  {

    GPIO_Init  ( GPIOx,  GPIO_Pin, GPIO_MODE_IN_PU_NO_IT )

    // write your routine

  }

  flag_GPIO_pull_up

= !

flag_GPIO_pull_up

;

  TIM1_ClearFlag(TIM1_FLAG_UPDATE);

}