ATMEGA 2560 (uGOAL)
- 1 Introduction
- 2 Software
- 2.1 Toolchain and flash tool
- 2.2 Building
- 2.3 Flashing
- 2.4 Serial Logging
- 3 Getting Started
- 3.1 Preparations
- 3.1.1 Hardware Requirements
- 3.1.2 ATMEGA 2560 Board
- 3.1.3 Target System
- 3.2 Debugging
- 3.2.1 UART
- 3.2.2 Application 02_profinet
- 3.1 Preparations
- 4 Known Issues
Introduction
The ATMEGA 2560 is a 8 bit CPU with 8kByte of SRAM and 256 kByte of Flash. It is capable as an application controller for the iRJ45/SoM module.
ATMEGA 2560 targets are only compatible with uGoal.
Software
Toolchain and flash tool
For compiling the example code, a AVR compiler is required. AVR-GCC can be obtained in several ways. Further information can be found here: http://avr-eclipse.sourceforge.net/wiki/index.php/The_AVR_GCC_Toolchain
For flashing the binary to the board AVRDUDE is required.
# on a MAC
brew tap osx-cross/avr
brew install avr-gcc avrdude
# on Linux
sudo apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude
# on Windows using msys2
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
pacman -S mingw-w64-x86_64-avr-gcc
pacman -S mingw-w64-x86_64-avr-libc
pacman -S mingw-w64-x86_64-avrdude
Building
Within a example folder of the software delivery (e.g. projects/ugoal/02_profinet/gcc) build the firmware with following commands:
make PLATFORM=atmega2560 clean all
Flashing
Flashing the firmware is done with the following command. Please use the UART device for your system.
make PLATFORM=atmega2560 UART=/dev/tty.usbmodem141401 flash serial
The Makefile target serial will use minterm.py from the pyserial package. Thus python and pyserial needs to be installed.
Serial Logging
On *nix systems the Makefile target serial can be used to open a serial terminal. This target uses the serial terminal from the pyserial package for python.
On windows systems a dedicated serial terminal should be used for serial logging (e.g. Putty).
Getting Started
Preparations
Hardware Requirements
Make sure following settings are set:
J13 - Connect “iRJ45” with “Sockel”
J8 - Connect “CS_SOURCE” with “PB2”
J7 - Connect “RST_SOURCE” with “PD7”
Set all DIP-Switches to “OFF”
ATMEGA 2560 Board
There is no configuration required.
Target System
Please connect both boards with each other, before you connect them per USB to your computer.
Please also see the Known Issues regarding the Connection between the ATMEGA2560 and the SoM.
In order for the SPI connection to work you need to add following wiring:
PMOD connector pin | Arduino pin | Function |
---|---|---|
1 (CS) | 53 | Chip select |
2 (MOSI) | 51 | MOSI |
3 (MISO) | 50 | MISO |
4 (SCK) | 52 | SCK |
Debugging
UART
The ATMEGA 2560 provides a UART over USB cable. Choose the following settings:
Speed | 28800 |
Data Bits | 8 |
Stop Bits | 1 |
Parity | Odd |
Flow Control | XON/XOFF |
Application 02_profinet
After setting up the serial monitor and starting the debug session, the output should look like this:
Known Issues
Following you’ll find current limitations regarding the ATMEGA 2560.
Some examples will not work since the platform provides insufficient resources. In general the uGOAL examples will work ( iRJ45 / SoM - uGOAL Examples ). Examples from the 20215013_irj45 folder ( iRJ45 / SoM - GOAL examples ) may need additional resources. This is specially the case when web server and tcp/udp channels are used in addition to a fieldsbus protocol.
Under specific conditions the SPI connection gets sporadically timeouts when using single wires connecting the SoM using the PMOD-Connectors. We highly recommend to separate the SPI-Signals MOSI, MISO, SCK and CS from each other using GND wires, to achieve proper shielding and a reliable SPI communication between the ATMEGA2560 and the SoM.