Reprogram ATMEGA8U2 on UNO SMD

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have an UNO SMD, and need to add just a few more digital IO.  If I can get the source code (and modify it), I can reprogram the device with an ATMEL-ICE programmer.

 

I have never used the Arduino environment - I develop in Atmel Studio (currently 7, but could go earlier if necessary).  However, I only know enough to be dangerous; I am not a programmer by trade.

I am looking for the source code currently in the ATEMGA8U2.  I would like to make a few minor mods (to use the four pins on JP2 and possibly the three on ICSP1), but leave the USB functionality [mostly] intact.  Where is the best place to find this code?

I found some examples in GitHub - the Arduino-usbserial project in the LUFA repository, but am not sure if these will work.  I am not entirely sure how to build the project using the makefile from within Atmel Studio (short of manually making a project, adding all dependencies, and tweaking command line options manually to do what the makefile is doing).  Is there a better way?

Science is not consensus. Science is numbers.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hobbss wrote:
Where is the best place to find this code?

ArduinoCore-avr/firmwares/atmegaxxu2 at master · arduino/ArduinoCore-avr · GitHub

Arduino Uno and Mega 2560 Firmwares for the ATmega8U2

...

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hobbss wrote:
the Arduino-usbserial project in the LUFA repository,
hobbss wrote:
I am not entirely sure how to build the project using the makefile from within Atmel Studio
hobbss wrote:
  Is there a better way?
There is a LUFA extension for AS7. When installed you can use a project creation wizard under File-New Project.. that allows you to select all the same projects that are also available as command line, makefile projects in the standard LUFA distribution.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey Cliff/Greg - long time no talk (long enough that you probably don't remember me).

 

Thanks for the feedback.  I have installed the ASF and LUFA extensions.  I created a project based on the sample project USB_TO_SERIAL (in LUFA?).

 

Apparently my schematic of the UNO is dated (and my eyes aren't that good).  Turns out the chip is actually an ATMEGA16U2, for what it is worth.  The sample project is targeting the AT90USB1287.  When I attempt to change it to the ATMEGA16U2, I get an error saying that ASF does not support device change "since some of the existing modules in the project may not work".  However, it then appears to change it.  Rebuilding the project succeeds.  However, when I reset the board, Windows throws a "USB device not recognized" error.  What foolish thing am I doing now? 

 

 

EDIT: Never mind... It was indeed foolish.  By default, the sample project had the clock source set to 8MHz.  Changed it to 16MHz, and all is now working.  Ironic, since I was just pondering how it was almost 10 years ago that I first read Cliff's signature, particularly the line about UART errors being related to clocking issues.

Science is not consensus. Science is numbers.

Last Edited: Thu. Jan 23, 2020 - 04:04 PM