ATmega4809 boards

The Arduino Nano Every and ATmega4809 Curiosity Nano are based on the Microchip ATmega4809, which is a slight upgrade to the popular ATmega328P used in the Arduino Uno.

It runs with a 20MHz internal oscillator, and so is a bit faster than the ATmega328P, and provides a more generous 48 Kbytes of flash memory and 6 Kbytes of RAM. This is still quite a limited amount of RAM, so by default uLisp restricts you to 3-character variable names to avoid the overhead of a symbol table. Unfortunately the ATmega4809 only provides 256 bytes of EEPROM, compared to the ATmega328P's 2 Kbytes, so save-image will only be usable for very short programs.

Arduino Nano Every

ArduinoNanoEvery.jpg

The Arduino Nano Every [1] is a low cost board based on the ATmega4809. It's available with or without headers.

I didn't originally recommend the Arduino Nano Every for uLisp because there were issues with its serial interface support, but the latest Arduino megaAVR Boards core seems to have fixed the issues, so I can now recommend it. It's supported by AVR uLisp Version 3.2 onwards.

LED

The Arduino Nano has a yellow LED connected to pin 13 which you can flash with the following program:

(defun bli (&optional x)
  (pinmode 13 t)
  (digitalwrite 13 x)
  (delay 1000)
  (bli (not x)))

Run it by typing:

(bli)

Exit from the program by entering ~.

ATmega4809 Curiosity Nano

Microchip's ATmega4809 Curiosity Nano evaluation board makes a very low-cost platform for running uLisp.

The ATmega4809 provides 48 Kbytes of flash memory, 6 Kbytes of RAM, and 256 bytes of EEPROM, and runs with a 20MHz internal oscillator. The board includes a debugger, providing a USB-to-serial interface:

CuriosityNano.jpg

It's available from suppliers such as Farnell [2].

Installing uLisp from the Arduino IDE

  • First download the latest AVR version of uLisp from the Download uLisp page.
  • Install MCUdude's MegaCoreX from GitHub, as described in MegaCoreX - How to install.
  • On the Board menu, under the heading MegaCoreX select Atmega4809.
  • Check that the subsequent options are set as follows (ignore any other options):

Clock: "20MHz"
Pinout: "48 pin standard"
Programmer: "Atmel nEDBG (ATSAMD21E18)"

  • Connect the board to the computer via USB.
  • Select the device corresponding to the USB port from the Port menu.
  • Upload uLisp to the board.

You should then be able to select Serial Monitor from the Tools menu, and enter Lisp commands.

LED

The Curiosity Nano has a yellow LED connected to pin 39 which you can flash with the following program:

(defun bli (&optional x)
  (pinmode 39 t)
  (digitalwrite 39 x)
  (delay 1000)
  (bli (not x)))

Run it by typing:

(bli)

Exit from the program by entering ~.

Pin 39 can also be used as an analogue output pin, so you can pulsate the yellow LED slowly on and off with this Pulse program:

(defun pls ()
  (loop
   (dotimes (x 512) 
     (delay 5) 
     (analogwrite 39 (if (> x 255) (- 511 x) x)))))

Run it by typing:

(pls)

As before, exit from the program by entering ~.

You can save the Pulse program to EEPROM by typing the command:

(save-image)

You can now load it again after a reset by typing:

(load-image)

Note that there's very little EEPROM on the ATmega4809, so this is close to the largest program you will be able to save with (save-image).


  1. ^ Arduino Nano Every with headers on Arduino Store.
  2. ^ DM320115 - Evaluation Board, Curiosity Nano, ATmega4809 on Farnell.

Previous: ATmega1284

Next: Arduino Zero