# GTimer disable

**URL:** <https://forum.amebaiot.com/t/gtimer-disable/3118>\
**Category:** Peripherals\
**Tags:** rtl8735b\
**Created:** [July 15, 2024, 10:32pm UTC](https://forum.amebaiot.com/t/gtimer-disable/3118 "2024-07-15T22:32:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsmith1024](https://avatars.discourse-cdn.com/v4/letter/n/bc79bd/32.png) [@nsmith1024](https://forum.amebaiot.com/u/nsmith1024)\
**Post date:** [July 15, 2024, 10:32pm UTC](https://forum.amebaiot.com/t/gtimer-disable/3118/1 "2024-07-15T22:32:39Z")

</div>

Hello,

Im using Gtimer like this below to call my tick function every 250 milliseconds

GTimer.begin(0, (1 \* 1000 \* 200), tick, true, 0);

However the tick function access some variables used by the main program, so i want to disable the GTimer while the main program is accessing those variables.

How can i disable the timer interrupts and re-enable it. like this

void setup()  
{  
GTimer.begin(0, (1 \* 1000 \* 200), tick, true, 0);  
}

void tick()  
{  
a=5;  
}

void loop()  
{  
disable\_timer\_interrupts(); \<\<\<\<----------------  
a=3;  
enable\_timer\_interrupts(); \<\<\<\<\<----------------  
}

how do i briefly disable and enable the timer tick interrupt from the GTimer?

Thanks

---

<div class="post-metadata">

**Author:** ![Pammy](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/pammy/32/936_2.png) [@Pammy](https://forum.amebaiot.com/u/Pammy)\
**Post date:** [July 24, 2024, 4:08am UTC](https://forum.amebaiot.com/t/gtimer-disable/3118/2 "2024-07-24T04:08:27Z")

</div>

You can refer to [GTimerClass Class – Realtek IoT/Wi-Fi MCU Solutions](https://www.amebaiot.com/en/rtl8735b-arduino-api-gtimerclass/)
