From 1dac965a8ceb8ac6f821883771f74d2b862069cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Fri, 17 Nov 2023 11:20:40 +0100 Subject: [PATCH 1/2] Added timers section --- .../tutorials/cheat-sheet/cheat-sheet.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/content/hardware/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md b/content/hardware/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md index e1cc9c76a5..3ae2aeec01 100644 --- a/content/hardware/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md +++ b/content/hardware/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md @@ -505,6 +505,25 @@ if(Serial.available() > 0) { } ``` +### Timers + +In the Ardunio API there is a [`FspTimer`](https://github.com/arduino/ArduinoCore-renesas/blob/149f78b6490ccbafeb420f68919c381a5bdb6e21/cores/arduino/FspTimer.h#L87) class which provides all the necessary functionality for using timers in a sketch. + +The UNO R4 WiFi has two timer peripherals, a Asynchronous General Purpose Timer (AGT) and a General PWM Timer (GPT). There are two AGT timers on the board, one of them is used for time measuring methods such as `millis()` and `microseconds()`. + +The board has 7 GPT timers to help perform PWM tasks. Such as calculating duty cycles by measuring how long a signal is active. It is possible to use these reserved pwm timers by using the previously mentioned [`FspTimer`](https://github.com/arduino/ArduinoCore-renesas/blob/149f78b6490ccbafeb420f68919c381a5bdb6e21/cores/arduino/FspTimer.h#L87) library. Using this function will explicitly request a PWM timer: + +```arduino +FspTimer::force_use_of_pwm_reserved_timer(); +``` + +When using the timer functions of the library you will need to enter the timers type. Which is either AGT or GPT. This can be declared in the sketch like this: + +```arduino +uint8_t gpt_timer_type = GPT_TIMER; +uint8_t agt_timer_type = AGT_TIMER; +``` + ### SerialUSB The UNO R4 WiFi has an extended set of Serial methods that can be enabled whenever you include the `` library in your sketch. From 783309fc8ffbd06126f04b6e45b153ec4a8bd9f3 Mon Sep 17 00:00:00 2001 From: BenjaminDannegard Date: Fri, 17 Nov 2023 11:41:06 +0100 Subject: [PATCH 2/2] Update content/hardware/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Karl Söderby <35461661+karlsoderby@users.noreply.github.com> --- .../boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/hardware/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md b/content/hardware/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md index 3ae2aeec01..e0b6846c97 100644 --- a/content/hardware/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md +++ b/content/hardware/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md @@ -511,7 +511,7 @@ In the Ardunio API there is a [`FspTimer`](https://github.com/arduino/ArduinoCor The UNO R4 WiFi has two timer peripherals, a Asynchronous General Purpose Timer (AGT) and a General PWM Timer (GPT). There are two AGT timers on the board, one of them is used for time measuring methods such as `millis()` and `microseconds()`. -The board has 7 GPT timers to help perform PWM tasks. Such as calculating duty cycles by measuring how long a signal is active. It is possible to use these reserved pwm timers by using the previously mentioned [`FspTimer`](https://github.com/arduino/ArduinoCore-renesas/blob/149f78b6490ccbafeb420f68919c381a5bdb6e21/cores/arduino/FspTimer.h#L87) library. Using this function will explicitly request a PWM timer: +The board has 7 GPT timers to help perform PWM tasks, such as calculating duty cycles by measuring how long a signal is active. It is possible to use these reserved PWM timers by using the previously mentioned [`FspTimer`](https://github.com/arduino/ArduinoCore-renesas/blob/main/cores/arduino/FspTimer.h#L87) library. Using this function will explicitly request a PWM timer: ```arduino FspTimer::force_use_of_pwm_reserved_timer();