ATmega4809 Curiosity Nano


#1

The AVR version of uLisp now supports Microchip’s ATmega4809 Curiosity Nano evaluation board, which 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:

It’s available from suppliers such as Farnell: Curiosity Nano Evaluation Board

Installing uLisp from the Arduino IDE

  • First download the latest AVR version of uLisp from the Download uLisp page.

On the Curiosity Nano board UART3 is connected to the serial port, so you need to add the following directive to the beginning of the uLisp source file to be able to use the serial port to enter Lisp programs:

#define Serial Serial3
  • 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.

LEDs

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)

To exit from the program enter ~ and press Return.


#2

The latest AVR version of uLisp, Version 2.9c, incorporates the serial port #define, so you don’t need to add this.

Another example:

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, to exit from the program enter ~ and press Return.

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)

#3

~. to exit… really? For all I remember, that was the combination to exit the classical “cu” utility on Unix, wasn’t it? And if so… you might reconsider it… for otherwise, one may throw oneself off one’s serial communication program rather than exit your program… ;)


#4

I didn’t know that - thanks. You could change the character used to exit in the uLisp source if it’s a problem.


#5

Actually, the ‘cu’ program used ~. on a new line to exit.
To exit ‘ulisp’ it’s just ~ 'cause the period that followed
was just “end of sentence” punctuation. :)


#6

I’ve rewritten that to make it clearer.


#7

👍