boards/atmega1284p: Add ATmega1284P as board
The ATmega1284P can be run on a breadboard with no external components, except for a power supply and (if access to the serial is required) an USB-TTL adapter. This commit adds it as a "board".
This commit is contained in:
parent
61c6b071b2
commit
8f03c7561a
5
boards/atmega1284p/Makefile
Normal file
5
boards/atmega1284p/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
MODULE = board
|
||||
|
||||
DIRS = $(RIOTBOARD)/common/atmega
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
1
boards/atmega1284p/Makefile.dep
Normal file
1
boards/atmega1284p/Makefile.dep
Normal file
@ -0,0 +1 @@
|
||||
USEMODULE += boards_common_atmega
|
||||
9
boards/atmega1284p/Makefile.features
Normal file
9
boards/atmega1284p/Makefile.features
Normal file
@ -0,0 +1,9 @@
|
||||
CPU = atmega1284p
|
||||
|
||||
FEATURES_PROVIDED += periph_adc
|
||||
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
|
||||
FEATURES_PROVIDED += periph_i2c
|
||||
FEATURES_PROVIDED += periph_pwm
|
||||
FEATURES_PROVIDED += periph_spi
|
||||
FEATURES_PROVIDED += periph_timer
|
||||
FEATURES_PROVIDED += periph_uart
|
||||
18
boards/atmega1284p/Makefile.include
Normal file
18
boards/atmega1284p/Makefile.include
Normal file
@ -0,0 +1,18 @@
|
||||
# configure the terminal program
|
||||
PORT_LINUX ?= /dev/ttyUSB0
|
||||
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
|
||||
BAUD ?= 9600
|
||||
ATMEGA328P_CLOCK ?=
|
||||
include $(RIOTMAKE)/tools/serial.inc.mk
|
||||
|
||||
# Allow overwriting programmer via env variables without affecting other boards
|
||||
PROGRAMMER_BOARD_ATMEGA1284P ?= dragon_isp
|
||||
# ICSP programmer to use for avrdude
|
||||
PROGRAMMER ?= $(PROGRAMMER_BOARD_ATMEGA1284P)
|
||||
|
||||
ifneq (,$(ATMEGA1284P_CLOCK))
|
||||
CFLAGS += -DCLOCK_CORECLOCK=$(ATMEGA1284P_CLOCK)
|
||||
endif
|
||||
|
||||
include $(RIOTMAKE)/tools/avrdude.inc.mk
|
||||
include $(RIOTBOARD)/common/atmega/Makefile.include
|
||||
101
boards/atmega1284p/doc.txt
Normal file
101
boards/atmega1284p/doc.txt
Normal file
@ -0,0 +1,101 @@
|
||||
/**
|
||||
@defgroup boards_atmega1284p Standalone ATmega1284P
|
||||
@ingroup boards
|
||||
@brief Support for using the ATmega1284P as standalone board
|
||||
|
||||
## Overview
|
||||
|
||||
As the ATmega1284P can run from the internal oscillator, placing it on a
|
||||
breadboard, connecting an USB-UART adapter and power is enough to run RIOT on
|
||||
it. (An ISP programmer will be needed to program it; or to program a bootloader
|
||||
to subsequently allow programming via UART.)
|
||||
|
||||
### MCU
|
||||
| MCU | ATmega328p |
|
||||
|:------------- |:-------------------------------------- |
|
||||
| Family | AVR/ATmega |
|
||||
| Vendor | Microchip (previously Atmel) |
|
||||
| RAM | 16KiB |
|
||||
| Flash | 128KiB |
|
||||
| EEPROM | 4KiB |
|
||||
| Frequency | 8MHz (up to 20MHz with external clock) |
|
||||
| Timers | 3 (2x 8bit, 1x 16bit) |
|
||||
| ADCs | 6 analog input pins |
|
||||
| UARTs | 1 |
|
||||
| SPIs | 1 |
|
||||
| I2Cs | 1 (called TWI) |
|
||||
| Vcc | 2.7V - 5.5V (when clocked at 8MHz) |
|
||||
| Datasheet | [Official datasheet](http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-42719-ATmega1284P_Datasheet.pdf) |
|
||||
|
||||
### Pinout
|
||||
|
||||
\htmlonly<style>div.image img[src="http://i.imgur.com/ayagBbM.png"]{width:50%;}</style>\endhtmlonly
|
||||
@image html "http://i.imgur.com/ayagBbM.png" "Pinout of the ATmega1284P"<br>
|
||||
|
||||
The pinout image was posted in the
|
||||
[Arduino Forum](https://forum.arduino.cc/index.php?topic=322745.0).
|
||||
All credit goes to its poster, hansibull.
|
||||
|
||||
### Clock Frequency
|
||||
|
||||
The ATmega1284P has two internal oscillators clocked at 8MHz and at 128kHz that
|
||||
allow it to be operated without any external clock source or crystal. By default
|
||||
the fuses are configured to use the internal 8MHz oscillator, but the `CKDIV8`
|
||||
fuse is set, so that the clock is divided down to 1MHz. By disabling the
|
||||
`CKDIV8` fuse the clock will operate at 8MHz. This is highly encouraged, and
|
||||
can be done with:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
avrdude -c dragon_isp -p m1284p -B 32 -U lfuse:w:0xc2:m
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
(Replace `dragon_isp` with the programmer you are using. The -B 32 might be
|
||||
needed for some programmers to successfully communicate with ATmegas clocked at
|
||||
less than 2MHz. It will no longer be needed after disabling `CKDIV8`.)
|
||||
|
||||
By setting the environment variable `ATMEGA1284P_CLOCK` to a custom frequency in
|
||||
Hz (e.g. `1000000` for 1MHz), this core clock can be changed easily. Refer to
|
||||
the datasheet on how to configure the ATmega1284p to use an external crystal,
|
||||
an external clock source or the clock divider.
|
||||
|
||||
### Relation Between Supply Voltage, Clock Frequency and Power Consumption
|
||||
|
||||
A higher supply voltage results in a higher current drawn. Thus, lower power
|
||||
consumption can be achieved by using a lower supply voltage. However, higher
|
||||
clock frequencies require higher supply voltages for reliable operation.
|
||||
|
||||
The lowest possible supply voltage at 8 MHz is 2.7V (with some safety margin).
|
||||
|
||||
## Flashing the Device
|
||||
|
||||
In order to flash the ATmega1284P without a bootloader, an ISP programmer is
|
||||
needed. Connect the programmer as follows:
|
||||
|
||||
| ISCP pin | ATmega1284P |
|
||||
|:-------- |:-------------- |
|
||||
| MISO | 7/PB6/MISO |
|
||||
| VCC | 10/VCC |
|
||||
| SCK | 8/PB7/SCK |
|
||||
| MOSI | 6/PB5/MOSI |
|
||||
| RESET | 9/RESET |
|
||||
| Ground | 11/GND |
|
||||
|
||||
The tool `avrdude` needs to be installed. When using the AVR Dragon for
|
||||
programming, running
|
||||
|
||||
make BOARD=atmega1284p flash
|
||||
|
||||
will take care of everything. To use the programmer `<FOOBAR>` instead, run
|
||||
|
||||
make BOARD=atmega1284p PROGRAMMER=<FOOBAR> flash
|
||||
|
||||
## Serial Terminal
|
||||
|
||||
Connect a TTL adapter with pins 14/RXD0 and 15/TXD0 an run
|
||||
|
||||
make BOARD=atmega1284p term
|
||||
|
||||
Please note that the supply voltage should be compatible with the logic level of
|
||||
the TTL adapter. Usually everything between 3.3 V and 5 V should work.
|
||||
|
||||
*/
|
||||
66
boards/atmega1284p/include/board.h
Normal file
66
boards/atmega1284p/include/board.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
|
||||
* 2016 Laurent Navet <laurent.navet@gmail.com>
|
||||
* 2019 Otto-von-Guericke-Universität Magdeburg
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup boards_atmega1284p
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Board specific definitions for the standalone ATmega1284P "board"
|
||||
*
|
||||
* @author Marian Buschsieweke <marian.buschsieweke@ovgu.de>
|
||||
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
|
||||
* @author Laurent Navet <laurent.navet@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef BOARD_H
|
||||
#define BOARD_H
|
||||
|
||||
#include "cpu.h"
|
||||
#include "periph_conf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
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)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name xtimer configuration values
|
||||
* @{
|
||||
*/
|
||||
#define XTIMER_WIDTH (16)
|
||||
#if CLOCK_CORECLOCK > 4000000UL
|
||||
#define XTIMER_HZ (CLOCK_CORECLOCK / 64)
|
||||
#else
|
||||
#define XTIMER_HZ (CLOCK_CORECLOCK / 8)
|
||||
#endif
|
||||
#define XTIMER_BACKOFF (40)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
|
||||
*/
|
||||
void board_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BOARD_H */
|
||||
/** @} */
|
||||
42
boards/atmega1284p/include/periph_conf.h
Normal file
42
boards/atmega1284p/include/periph_conf.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Otto-von-Guericke-Universität Magdeburg
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup boards_atmega1284p
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Peripheral MCU configuration for the ATmega1284p standalone "board"
|
||||
*
|
||||
* @author Marian Buschsieweke <marian.buschsieweke@ovgu.de>
|
||||
*/
|
||||
|
||||
#ifndef PERIPH_CONF_H
|
||||
#define PERIPH_CONF_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 */
|
||||
Loading…
x
Reference in New Issue
Block a user