Introduction: ATmega DIP40 in Arduino IDE 1.6.4

Picture of ATmega DIP40 in Arduino IDE 1.6.4

Quick solution for use some ATmega microcontrollers in newer Arduino IDE ver. 1.6.4

As we know, recent changes in the Arduino world have boosted development of Arduino IDE, now reached version 1.6.4.

I do not want to talk at all of the war Arduino LLC vs Arduino SRL (not now, not here). In fact I think my opinion on this topic is not important.

So, I downloaded and try versions 1.6.2/1.6.4 from Arduino.cc and 1.7.2 from Arduino.org (1.7.3 not tested yet).

And I decided to go ahead with 1.6.4 from Arduino.cc / Arduino LLC http://www.arduino.cc/en/Main/Software.

I took the opportunity and did some cleaning in the files pins_arduino.h for ATmega1284, ATmega32 and ATmega16. I remove defines for A0-A7. We can access all 32 digital pins with digitalRead(0 ... 31) / digitalWrite (0 ... 31,[...]) and ADC pins with analogRead(0..7).

Let's start!

Step 1: Select Preferences

Picture of Select Preferences

Select Preferences from File menu.

Step 2:

Picture of

Edit Additional Boards Manager URLs field and put this link:

http://openhardware.ro/boards/package_openhardwarero_index.json

Step 3: Open Board Manager

Picture of Open Board Manager

And wait a little...

Step 4: Install Boards

Picture of Install Boards

Yes it is easier now.

Step 5: Done

Picture of Done

Now it's done. Almost :)

For ATmega1284 any change is no longer necessary.

For ATmega32 and ATmega16 we need to edit

...\arduino-1.6.4\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp

we will replace:

#if defined(__AVR_ATmega8__)
	config |= 0x80; // select UCSRC register (shared with UBRRH) 
#endif

with:

#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega32__) || defined(__AVR_ATmega16__)
	config |= 0x80; // select UCSRC register (shared with UBRRH) 
#endif

Step 6: Finally

Picture of Finally

Please note: This is a project in progress. It may have some errors. I tested compiling and uploading some examples for ATmega1284/32/16.

At this moment are defined six "boards"(usually I work with these microcontrollers.):

  • ATmega16-8MHz
  • ATmega16-16MHz
  • ATmega32-8MHz
  • ATmega32-16MHz
  • ATmega1284-16MHz
  • ATmega1284-20MHz

I intend to include ATmega644 and ATmega1284P, but it will take some time (I have no one handy). I plan to buy two of every and and put them on these small boards like above.

You can also read: https://www.instructables.com/id/ATmega-DIP40-Mini...

Have fun!

Comments

JakubM38 (author)2017-07-08

Everything work for me fine. My own board blink very nice. Thank You very much.

Silvius (author)JakubM382017-07-13

You're welcome!

I'm glad to hear that. Good luck!

AhmedY61 (author)2017-06-16

i get this error when i am trying to install the package.

AhmedY61 (author)AhmedY612017-06-16

trying to download the link

Silvius (author)AhmedY612017-06-16

Problem solved. Still I do not know why the file has disappeared.

You can try again now.

AhmedY61 (author)Silvius2017-06-16

thank you it works

Silvius (author)AhmedY612017-06-16

You are right. I do not know why the file has disappeared.

I'll see what it's about in a matter of hours.

MoizA11 (author)2016-10-16

I am receiving an error, " avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp' ". I am using ATMEGA32... I use the same USBasp to write hex files created by Atmel studio (using Extreme AVR burner)... in this case its not working... please help.

Silvius (author)MoizA112016-10-16

It seems that avrdude not "see" USBasp device. Maybe was "locked" by "Extreme AVR burner" program (You have not closed the program?)... or USBasp device have a different vid/pid form what avrdude is configured? I notice that device is working device... but message is from avrdude included in Arduino IDE... I sugest to try a separate version of avrdude... to see if working...

...or restart, plug USBasp in another USB socket an try first with Arduino IDE...

...look after usb devices in your operating system configuration to see how this device is used... what are vid/pid... and other info...

Some USBasp clones (I use them too) do not have the "official" version of firmware... mine worked also in linux and windows... but maybe an updated firmware will solve this problem... you can try to update usbasp with another usbasp... and a known working program like Extreme burner"

MoizA11 (author)Silvius2016-10-16

this " error" I talked earlier was in Arduino IDE 1.6... (I did not use avrdude)

Silvius (author)MoizA112016-10-17

I know that error was in Arduino IDE... more precisely in avrdude that is bundled with Arduino IDE 1.6.xx... You can search in Arduino IDE installation folders and you will see... somewhere in .../arduino-1.6.x/hardware/tools/avr/bin... there are avrdude files...

after the latest additions(of informations) you've made I only see that Arduino IDE not installed properly ... or has altered thereafter... I don't think that has to do with definitions for DIP Atmega 40, because these definitions use tools and config files that are already there...

Right now I use 1.6.7 under Linux Ubuntu... and method/files from this instructable...

MoizA11 (author)Silvius2016-10-16

a strange thing happened... I (just out of curiosity) used an older version of Arduino IDE 1.5.2 and this same USBasp device worked perfectly...

HosseinM8 (author)2016-09-14

hi. i want to monitor values on IDE serial monitor but it not working. would you help me please.

VishalM17 (author)2016-07-15

HEY TIMERONE LIBRARY IS NOT WORKING IN ARDUINO ATMEGA32 DO ANY ONE HAVE SOLUTION I NEED TO USE TIMER FOR DELAY, MY MAIL ID IS vishal.mhatre390@gmail.com

tejass20 (author)2016-07-01

hello i m trying to check the special peripheral of atmega 1284, but i am not able to fetch datda like usart, adc. kindly share the data if available

Silvius made it! (author)tejass202016-07-08

Ok. This is my setup:

1) Small dev. board for Atmega DIP40 (my design);

2) RS232 to TTL module (my design also)

3) USB to RS232 adapter (or a serial cable if your computer has serial port)

4) cheap 5KOhm potentiometer. Middle pin is wired to PA0 (pin40). Other two pins to VDD and GND.

Ande here is the code (as simple as possible):

int firstSensor = 0;

void setup() {
Serial.begin(9600);
}

void loop() {
firstSensor=analogRead(0);
Serial.println(firstSensor);
delay(1000);
}

I guarantee you it works...

Silvius (author)tejass202016-07-08

Right now I do some tests for you... I'll come back with some feedback within hours. I do not have an I2C lcd, so I will try Serial with ADC and eventually with a ordinary 16x2 lcd...

Silvius (author)tejass202016-07-03

I want to help you in one way or another, but I do not understand what the problem is ... I use this setup to make to do all kinds of projects... including usart and adc with atmega 32 16 and 1284

tejass20 (author)Silvius2016-07-04

i am using these for adc and usart in one of my project but neither is working i am using proteus to test my code, those code when used in uno using uno board work fine but when using these board i dump in atmega1284p in proteus it dont work plz help me out

tejass20 (author)tejass202016-07-04

THIS IS MY CODE

/*-----( Import needed libraries )-----*/

#include <Wire.h> // Comes with Arduino IDE

#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/

/*-----( Declare objects )-----*/

// set the LCD address to 0x27 for a 20 chars 4 line display

// Set the pins on the I2C chip used for LCD connections:

// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

int sensorPin = A0; // select the input pin for the potentiometer

float vtg;

int sensorValue = 0;

/*-----( Declare Variables )-----*/

//NONE

void setup() /*----( SETUP: RUNS ONCE )----*/

{

Serial.begin(9600); // Used to type in characters

//pinMode(sensorPin, INPUT);

lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines, turn on backlight

// ------- Quick 3 blinks of backlight -------------

for(int i = 0; i< 3; i++)

{

lcd.backlight();

delay(50);

lcd.noBacklight();

delay(50);

}

lcd.backlight(); // finish with backlight on

//-------- Write characters on the display ------------------

// NOTE: Cursor Position: (CHAR, LINE) start at 0

//

// delay(1000);

// lcd.setCursor(0,3);

// lcd.print("4th Line of Text");

// delay(8000);

// Wait and then tell user they can start the Serial Monitor and type in characters to

// Display. (Set Serial Monitor option to "No Line Ending")

/* lcd.clear();

lcd.setCursor(0,0); //Start at character 0 on line 0

lcd.print("Use Serial Mon");

lcd.setCursor(0,1);

lcd.print("Type to display"); */

}/*--(end setup )---*/

void loop() /*----( LOOP: RUNS CONSTANTLY )----*/

{

sensorValue = analogRead(sensorPin);

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("adc:");

lcd.print(sensorValue);

delay(500);

lcd.setCursor(0,1);

lcd.print("vtg:"); // Print text on 2nd Line

vtg=((5.0/1023)*sensorValue);

lcd.print(vtg);

// delay(1000);

// lcd.setCursor(0,2);

// lcd.print("0123456789ABCDEFGHIJ"); //Print 20 characters on 3rd line

}/* --(end main loop )-- */

/* ( THE END ) */

tejass20 (author)tejass202016-07-04

if you have code of simple adc and uart please if you can share it, it would help me alot for 1284p

AngeloV9 (author)2016-06-15

Hi Guys,

I developed a scketch to work on Arduino Mega and I need to compile in an AtMega1284p-pu
- Can I compile the same scketch in Atmega1284p-pu?
- Is it necessary to change anything on the scketh? pins for example?
- The AtMega1284p-pu is still a "virgin", which Arduino's bootloader is better to burn in?

Thanks

Angelo Ventura

Silvius (author)AngeloV92016-06-18

I tried to answer your question here:

http://openhardware.ro/using-atmega32-arduino-ide/...

marc.deloor.5 (author)2015-10-16

Thank you very much for this instructable! I recently asked the groups a question on how to use a AtMega 32. Then I saw your instructable how to make a DIP 40 mini board, and this instructable. I hope I can finally get those ATMegas running! Just 1 question: I would use FTDI chips to connect the board to the PC, would that work?

Silvius (author)marc.deloor.52015-10-18

Hm... Some notifications from Instructable reach spam folder at my Yahoo mail... not all .. just some...

I think you already find the solution...

IancuG (author)2015-10-12

same problem as TIMLM.. can you help me please to modify the fuse ? when i put (1000) delay i have to wait 17 seconds.... 16Mhz. thanks

Silvius (author)IancuG2015-10-13

What kind of ATmega (16,32 or 1284)?

for ATmega16 and 32 you can use High Fuse 0xD9, and Low Fuse 0xFF

External Crystal upto 16MHz, JTAG disabled. Rest of the options : Default.

Avrdude arguments: -U lfuse:w:0xff:m -U hfuse:w:0xd9:m

IancuG (author)Silvius2015-10-13

atmega32, but where can i change the fuse ? i don't fund the installed boards because they are not in the board.txt...

Silvius (author)IancuG2015-10-13

Here is a tutorial about fuse bits: https://embedderslife.wordpress.com/2012/08/20/fus... and another: http://www.ladyada.net/learn/avr/fuses.html

You can change fusebits with avrdude:

avrdude [..........] -U lfuse:w:0xff:m -U hfuse:w:0xd9:m

or with eXtreme Burner: http://extremeelectronics.co.in/avr-tutorials/gui-...

mbojanic (author)2015-06-04

Error while burning bootloader: missing 'bootloader.tool' configuration parameter

Silvius (author)mbojanic2015-06-04

Entire solution was designed to be used without bootloader ... but with USBASP or other programmer recognized by Arduino IDE. I always work this way... using bootloader seems to me an unnecessary complication (when I working with standalone microcontroller)...

TIMLM (author)Silvius2015-08-03

@Silvius. Thanks for the sharing this. I'm using the ATmega16 and it works great except for a timing issue. When I write delay(1000), the actual delay ends up being about 8 seconds. Just thought that I'd let you know. Thanks again.

Silvius (author)TIMLM2015-08-03

Thanks for feedback! It looks like you are selected board "ATmega16-8Mhz" but fusebits are left with default values 1MHz. You must change fusebits according with your usage.

Look here http://www.ladyada.net/learn/avr/fuses.html

TIMLM (author)Silvius2015-08-04

Oh right should have thought of that. I used the link to get the correct fuse bits and used atmel studio and the avrisp mkII to change them. Now the timing is as it should be. Any advice as to how someone might change the bits using only an Arduino? I'm guessing I could do it w/ avrdude, but the device signature I was getting was that of the ATmega328p on the Arduino.

Silvius (author)TIMLM2015-08-05

I think that Arduino IDE can burn fusebits only with bootloader. I not tested it because I never use bootloader with my custom “boards”, so microcontrollers must be set up before being used (It is one time procedure anyway). This is the limit of my solution. As you can see it is easy to overcome.


I'm not enemy of bootloaders, but these require some specific hardware, and I would not know in advance what kind of board will be used...


So to prevent some errors/issues which could lead to “brick” some MCUs, I decided to leave this operation to be made explicit, and the user to know (or learn) what he does.
Best regards!

mbojanic (author)2015-06-04

thsi will actually never work on arduini IDE 1.6.4

you have mised the main changes in boards file... also clock and cpu have been split in 2 different segments.. you are aware of that... so therefore boards file has to re-written properly to form what's necessary in order to get it working properly...

Silvius (author)mbojanic2015-06-04

Hm... Curious ... I actually work with this these files and Arduino 1.6.4... and I tested installation (I delete, uninstall an reinstall for many times), at first on local server and second from link given in instructable...

And after I compiled and run some tests for every MCU in the list... and everything working fine...

I'll check anyway...

About This Instructable

31,710views

35favorites

License:

More by Silvius:Reading 15 Rotary Encoders with Arduino and ATmega1284Open Source TV Box - GeekBoxAVR Transistor Tester
Add instructable to: