From 498cbe9bbcf3d95a96cc4a7303ef9fbce93496e3 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 6 Nov 2019 07:28:39 +0100 Subject: [PATCH 1/5] boards/atmega256rfr2-xpro: configure external 16MHz oscillator --- boards/atmega256rfr2-xpro/include/board.h | 6 ++---- boards/atmega256rfr2-xpro/include/periph_conf.h | 14 ++------------ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/boards/atmega256rfr2-xpro/include/board.h b/boards/atmega256rfr2-xpro/include/board.h index 327958937e..356feba78c 100644 --- a/boards/atmega256rfr2-xpro/include/board.h +++ b/boards/atmega256rfr2-xpro/include/board.h @@ -44,13 +44,11 @@ extern "C" { /** * @name xtimer configuration values * - * Xtimer runs at 8MHz / 64 = 125kHz + * Xtimer runs at 16MHz / 64 = 250kHz * @{ */ -#define XTIMER_DEV (0) -#define XTIMER_CHAN (0) #define XTIMER_WIDTH (16) -#define XTIMER_HZ (125000UL) +#define XTIMER_HZ (250000UL) #define XTIMER_BACKOFF (40) /** @} */ diff --git a/boards/atmega256rfr2-xpro/include/periph_conf.h b/boards/atmega256rfr2-xpro/include/periph_conf.h index 5c65b2290c..62e7770726 100644 --- a/boards/atmega256rfr2-xpro/include/periph_conf.h +++ b/boards/atmega256rfr2-xpro/include/periph_conf.h @@ -19,24 +19,14 @@ #ifndef PERIPH_CONF_H #define PERIPH_CONF_H +#include "periph_conf_atmega_common.h" + #ifdef __cplusplus extern "C" { #endif -/** - * @name Clock configuration - * @{ - */ -#ifndef CLOCK_CORECLOCK -/* Using 8MHz internal oscillator as default clock source */ -#define CLOCK_CORECLOCK (8000000UL) -#endif -/** @} */ - #ifdef __cplusplus } #endif -#include "periph_conf_atmega_common.h" - #endif /* PERIPH_CONF_H */ From 485bfc45da633c2dca92833b0159d75077eeb9a7 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 6 Nov 2019 07:29:32 +0100 Subject: [PATCH 2/5] boards/atmega256rfr2-xpro: document how to configure the fuses This is important for a correct configuration of the external 16MHz oscillator --- boards/atmega256rfr2-xpro/doc.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/boards/atmega256rfr2-xpro/doc.txt b/boards/atmega256rfr2-xpro/doc.txt index 1c7d677cad..1ac5d747a4 100644 --- a/boards/atmega256rfr2-xpro/doc.txt +++ b/boards/atmega256rfr2-xpro/doc.txt @@ -11,7 +11,20 @@ is an evaluation kit by Microchip for their ATmega256RFR2 microcontroller. ### Flash the board You can flash the board using the on-board EDBG programmer via JTAG. Avrdude has -support for programming an AVR via EDBG with its xplainedpro programmer: +support for programming an AVR via EDBG with its xplainedpro programmer. + +First, make sure the default fuse settings are correct. In particular, the low +byte fuse are enabling the use of the on-board 16MHz external oscillator.
+ +WARNING: setting the fuses incorrectly can brick your board! +``` +avrdude -p m256rfr2 -c xplainedpro -U efuse:w:0xFF:m +avrdude -p m256rfr2 -c xplainedpro -U hfuse:w:0x1F:m +avrdude -p m256rfr2 -c xplainedpro -U lfuse:w:0xFF:m +``` + +To flash the board, just call `make` from an application directory with the +`flash` target: ``` make BOARD=atmega256rfr2-xpro -C examples/hello-world flash From 42c4b7d34dcc7df4bb39f1c8f9ced4468174ead5 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 6 Nov 2019 08:11:52 +0100 Subject: [PATCH 3/5] boards/atmega256rfr2-xpro: use 115200 baudrate for STDIO --- boards/atmega256rfr2-xpro/Makefile.include | 2 +- boards/atmega256rfr2-xpro/include/board.h | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/boards/atmega256rfr2-xpro/Makefile.include b/boards/atmega256rfr2-xpro/Makefile.include index 3f55b658d4..1da4566356 100644 --- a/boards/atmega256rfr2-xpro/Makefile.include +++ b/boards/atmega256rfr2-xpro/Makefile.include @@ -1,7 +1,7 @@ # configure the terminal program PORT_LINUX ?= /dev/ttyACM0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) -BAUD ?= 9600 +BAUD ?= 115200 include $(RIOTMAKE)/tools/serial.inc.mk # Use EDBG (xplainedpro) programmer with avrdude diff --git a/boards/atmega256rfr2-xpro/include/board.h b/boards/atmega256rfr2-xpro/include/board.h index 356feba78c..7e4edde9fa 100644 --- a/boards/atmega256rfr2-xpro/include/board.h +++ b/boards/atmega256rfr2-xpro/include/board.h @@ -26,16 +26,6 @@ extern "C" { #endif -/** - * @name STDIO configuration - * - * As the CPU is too slow to handle 115200 baud, we set the default - * baudrate to 9600 for this board - * @{ - */ -#define STDIO_UART_BAUDRATE (9600U) -/** @} */ - /** * @brief Use the UART 1 for STDIO on this board */ From cab3cc473e51968349aa2a337abe5a2a2610d66a Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 6 Nov 2019 07:30:43 +0100 Subject: [PATCH 4/5] tests/periph_timer: add atmega256rfr2-xpro to boards with 25KHz timer --- tests/periph_timer/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/periph_timer/Makefile b/tests/periph_timer/Makefile index 1f00d7726a..2e68164141 100644 --- a/tests/periph_timer/Makefile +++ b/tests/periph_timer/Makefile @@ -7,6 +7,7 @@ BOARDS_TIMER_25kHz := \ arduino-leonardo \ arduino-mega2560 \ arduino-uno \ + atmega256rfr2-xpro \ atmega328p \ waspmote-pro \ # From bd39ce31795e797dd8905f42cf1a6281bd9a1b36 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 6 Nov 2019 07:37:06 +0100 Subject: [PATCH 5/5] tests/periph_gpio: increase timeout for automatic test periph_gpio requires more time to complete on slow platforms, like AVR --- tests/periph_gpio/tests/02-bench.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/periph_gpio/tests/02-bench.py b/tests/periph_gpio/tests/02-bench.py index e1cc79c21f..ea2d00371a 100755 --- a/tests/periph_gpio/tests/02-bench.py +++ b/tests/periph_gpio/tests/02-bench.py @@ -10,6 +10,10 @@ import sys from testrunner import run +# On slow platforms, like AVR, this test can take some time to complete. +TIMEOUT = 30 + + def testfunc(child): child.expect_exact("GPIO peripheral driver test") child.expect_exact(">") @@ -33,4 +37,4 @@ def testfunc(child): if __name__ == "__main__": - sys.exit(run(testfunc, timeout=10)) + sys.exit(run(testfunc, timeout=TIMEOUT))