Ameba Arduino: [RTL8195AM] [RTL8710AF] Timer - Using the periodic GTimer
- Ameba x 1
|0||Share with PWM_3|
|1||Share with PWM_0|
|2||Share with PWM_1|
|3||Share with PWM_2|
|4||Share with software RTC|
The timer can be set to be periodic or for single use. The periodic timers reset periodically, and the single-use timers don’t.
Open the example, “File” -> “Examples” -> “AmebaGTimer” -> “timer_periodical”. Compile and upload to Ameba, and press reset.
In the Serial Monitor, you can see the counter value is increased periodically.
The second argument is the value of the timer (in microseconds). In the example, we fill in 1000000us = 1s.
The third argument specifies the funcion to call when the time is up. In the example, we call the “myhandler” function to increase the counter value by 1 and print the counter value to serial monitor.
GTimer.begin(0, 1 * 1000 * 1000, myhandler);
The GTimer is periodic by default, therefore “myhandler” function is called every second.
When we want to stop the GTimer, use “stop()”: