Build a simple Webserver with Pollin AVR-NET-IO using the Arduino software stack

0. Programmer

I'm using an Arduino as ISP to flash the webserver to the AVR-NET-IO. See my previous post Dump ATMEGA32 on AVR-NET board using avrdude for how to convert the Arduino to a programmer and how to wire the connections between the Arduino (programmer) and the AVR-NET-IO. Do not connect AVR-NET-IO's own power source when it is connected to the Arduino (programmer).

1. ATmega32

The AVR-NET-IO uses the ATmega32 microcontroller about which the Arduino IDE does not know anything. Thankfully, Eric Conner has written a definition file for the ATmega32 needed by the Arduino IDE.

1.1. Download definitions from https://github.com/eaconner/ATmega32-Arduino and follow the instructions to install the mega32 variant files.

1.2. Patch the pins_arduino.h file to contain the following additional lines:

static const uint8_t SS   = 4; // D4
static const uint8_t MOSI = 5; // D5
static const uint8_t MISO = 6; // D6
static const uint8_t SCK  = 7; // D7

I have the file in the following directory:

%USERPROFILE%\Documents\Arduino\hardware\mega32\variants\mega32\pins_arduino.h

2. ENC28J60 network chip

The Pollin board also contains an ENC28J60 network chip. This cannot be addressed by the Arduino Ethernet library directly but there is a wonderful replacement library available from Norbert Truchsess at

https://github.com/ntruchsess/arduino_uip

Install the library as described in the installation instructions on the above link.

I have the library files in the following directory:

%USERPROFILE%\Documents\Arduino\libraries\UIPEthernet

e.g. the file %USERPROFILE%\Documents\Arduino\libraries\UIPEthernet\Dhcp.cpp

3. Webserver

3.1. Start Arduino IDE, open from the menu Examples / Ethernet / WebServer .

3.2. Change the include directive

#include <Ethernet.h>

to

#include <UIPEthernet.h>

4. Compile and Upload

4.1. In Arduino IDE menu select: Tools / Programmer / Arduino as ISP

4.2.  Select Tools / Board / ATmega32-External 16MHz

4.3. File / Upload using Programmer (this sometimes aborts with error message "Not int sync". Simply give it a second try.

4.4. Make sure to disconnect the Arduino (programmer) from the AVR-NET-IO before you connect AVR-NET-IO's own power source.

Read fuses of ATMEGA32 on AVR-NET-IO

Same configuration as described in the previous post Dump ATMEGA32 on AVR-NET board using avrdude. Then

bin\avrdude.exe -C etc\avrdude.conf -c avrisp -p ATMEGA32 -P com4 -b 19200 -v

The output for was


avrdude.exe: Version 5.11, compiled on Sep  2 2011 at 19:38:36
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2009 Joerg Wunsch

             System wide configuration file is "etc\avrdude.conf"

             Using Port                    : com4
             Using Programmer              : avrisp
             Overriding Baud Rate          : 19200
             AVR Part                      : ATMEGA32
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PA0
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :

                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom         4    10    64    0 no       1024    4      0  9000  9000 0xff 0xff
               flash         33     6    64    0 yes     32768  128    256  4500  4500 0xff 0xff
               lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
               lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
               calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00

             Programmer Type : STK500
             Description     : Atmel AVR ISP
             Hardware Version: 2
             Firmware Version: 1.18
             Topcard         : Unknown
             Vtarget         : 0.0 V
             Varef           : 0.0 V
             Oscillator      : Off
             SCK period      : 0.1 us

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude.exe: Device signature = 0x1e9502
avrdude.exe: safemode: lfuse reads as FF
avrdude.exe: safemode: hfuse reads as CA
avrdude.exe: current erase-rewrite cycle count is -1062731548 (if being tracked)

avrdude.exe: safemode: lfuse reads as FF
avrdude.exe: safemode: hfuse reads as CA
avrdude.exe: safemode: Fuses OK

avrdude.exe done.  Thank you.

Use the Engbedded Atmel AVR® Fuse Calculator to interpret the values

lfuse reads as FF
hfuse reads as CA

from the output above.

Clock source

CKSEL3 [ ]
CKSEL2 [ ]
CKSEL1 [ ]
CKSEL0 [ ]

means External crystal

Boot

BOOTSZ1 [X]
BOOTSZ0 [ ]

means Boot size 1024 words

BOOTRST [X]

means program counter points to bootloader (instead of 0xC00) after reset