Arduino Forum

Using Arduino => Microcontrollers => Topic started by: aalavandhaann on Aug 16, 2012, 11:52 am

Title: Burning Arduino to ATmega32A
Post by: aalavandhaann on Aug 16, 2012, 11:52 am
Dear Friends,

I have an USBASP programmer and a couple of ATmega32A(unfortunately this is the most sold controller at my place) lying around. I wish to know if i can burn an Arduino Bootloader onto it to take advantage of using Arduino framework for writing my applications. Because more than AVR, Arduino suits me better for the greater society, ease in learning curve on the programming front (sorry i find Arduino a bit easier than AVR). Also I found a site where they have given the pin mapping of the ATMega32 http://retrointerfacing.com/?p=30 (http://retrointerfacing.com/?p=30).

Can someone help me through this? I do not mind burning my application hex files manually or to discard the Arduino IDE. All i need is a way to figure out running my Arduino framework based programs on my ATmega32 for which I believe the Arduino bootloader has to be burned into before.

Regards,

Ashok Srinivasan.
Title: Re: Burning Arduino to ATmega32A
Post by: CrossRoads on Aug 16, 2012, 10:04 pm
Go to www.avr-developers.com and download the files for ATMega32.
May need to create a new board type in boards.txt and make an entry in avrdude.conf after that.
IDE 1.0.1 has an updated structure that supports "variants" of microcontrollers. I'm not knowledgeable enough really descibe it better for you.
Title: Re: Burning Arduino to ATmega32A
Post by: aalavandhaann on Aug 18, 2012, 03:38 pm

Go to www.avr-developers.com and download the files for ATMega32.
May need to create a new board type in boards.txt and make an entry in avrdude.conf after that.
IDE 1.0.1 has an updated structure that supports "variants" of microcontrollers. I'm not knowledgeable enough really descibe it better for you.


Firstly, thanks for your time and reply. Got it boss. One more thing to boot up the process, will this version work under 1.0.1 or do I have to use any specific version(ex., in the site you have mentioned 0.20)

Regards,

Ashok Srinivasan

Title: Re: Burning Arduino to ATmega32A
Post by: CrossRoads on Aug 18, 2012, 04:57 pm
Give it a try with 1.0.1, can always go back to -0020 if it doesn't work.

avrdude.conf already has the info for atmega32.
You'll have to make a new boards.txt entry for the device.
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 26, 2013, 06:03 pm
Thanks for the link. But the website seems to be old enough. Cant find the proper files. The described link is also dead. Any help on that, please?
http://www.avr-developers.com/bootloaderdocs/index.html
http://www.icy.com.au/
Cant find ATmega32A core files in Arduino-extras.zip file.
Any solutions?
Thanks.



Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 27, 2013, 08:56 am
Hi,

Found another page with ATmega32 configuration files. http://retrointerfacing.com/?p=30=1
Downloaded the .zip files.
In the boards.txt file included in the zip, it shows the configuration for mega32 chip. But the 32 & 32A are different chips. I used that page to find out the fusebit config.  http://www.engbedded.com/fusecalc
Well, they have also listed 2 different pages for 2 different chips.

What should I do in that situation? I'll be using the 32A chip trying to implement the "playing tones based on micros()" http://forum.arduino.cc//index.php?topic=179761.0

Both the ATmega1284 & 32A are 40 pin IC with same port pin numbers. 32A is having few less pwm pins & other functionalities.
(http://blog.protoneer.co.nz/wp-content/uploads/2013/05/atmega1284_pinout.png)

(http://circuits.datasheetdir.com/18/ATMEGA32-pinout.jpg)
Will the code run on my 32A chip anyhow? any suggestions please.
Thanks for the support.
Good day.
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 27, 2013, 11:38 am
Hello,

I tried to upload the ATmega32 bootloader on my ATmega32A chip using arduino & usbasp programmer.

The error I'm getting is
Code: [Select]
"efuse" memory type not defined for part "ATMEGA32"

Procedure followed:
Downloaded the attached zip file. (included in the post)
copied the ATmegaBOOT_32.hex & .c file to "C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\bootloaders\atmega32\"
Added the modified code to boards.txt
Opened arduino 1.0.5
Tools> Boards> ATmega32board
Tools> Programmer> USBasp

The modified & added part of boards.txt
Code: [Select]
##############################################################

atmega32.name=ATmega32board
atmega32.upload.protocol=arduino  // Changed it from "STK500" to "arduino"
atmega32.upload.maximum_size=28336
atmega32.upload.speed=115200 // changed it from "19200" to "115200"
atmega32.bootloader.low_fuses=0xff
atmega32.bootloader.high_fuses=0xdd
atmega32.bootloader.extended_fuses=0x00
atmega32.bootloader.path=atmega32            // default was "atmega8", I created an atmega32 folder under  the
atmega32.bootloader.file=ATmegaBOOT.hex             //bootloader folder & changed the path.
atmega32.bootloader.unlock_bits=0x3F
atmega32.bootloader.lock_bits=0x0F
atmega32.build.mcu=atmega32
atmega32.build.f_cpu=16000000L
atmega32.build.core=arduino
uno328.build.variant=standard

##############################################################


It is the issue I suppose.
Code: [Select]
atmega32.bootloader.extended_fuses=0x00
The fusecalc web page doesn't show any trace of extended fuse feature in both ATmega32 & 32A.
http://www.engbedded.com/fusecalc
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 27, 2013, 12:33 pm
Deleted the efuse configuration & the bootloader successfully uploaded to ATmega32A.
Having issue with uploading the blink sketch into that chip. The error report says...
Code: [Select]
In file included from Blink.ino:10:
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/Arduino.h:213:26: error: pins_arduino.h: No such file or directory

Any suggestions?
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 27, 2013, 03:44 pm
I put the arduino-mega32-mod.zip file (included in the post) contents  to the arduino core directory "C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino". The zip has the "pins_arduino.h" file that was to be there in the "core" folder. I overlooked the step then finally fixed it. now the issue lies on an other point.

I am trying to upload the blink sketch & now the error shown is...
Code: [Select]
In file included from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/Arduino.h:213,
                from Blink.ino:10:
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/pins_arduino.h:45: error: conflicting declaration 'const uint8_t port_to_mode_PGM []'
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/Arduino.h:127: error: 'port_to_mode_PGM' has a previous declaration as 'const uint16_t port_to_mode_PGM []'
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/pins_arduino.h:46: error: conflicting declaration 'const uint8_t port_to_input_PGM []'
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/Arduino.h:128: error: 'port_to_input_PGM' has a previous declaration as 'const uint16_t port_to_input_PGM []'
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/pins_arduino.h:47: error: conflicting declaration 'const uint8_t port_to_output_PGM []'
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/Arduino.h:129: error: 'port_to_output_PGM' has a previous declaration as 'const uint16_t port_to_output_PGM []'


The page from where I get the ATmega32 arduino files is...
http://retrointerfacing.com/?p=30=1

Any clue on how to fix that?
Thanks for the co-operation.
Title: Re: Burning Arduino to ATmega32A
Post by: CrossRoads on Dec 27, 2013, 03:57 pm
Keep slogging away! You'll get the little things fixed ...
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 27, 2013, 07:28 pm
Thanks for your reply CrossRoads. Well, I think that there is somekind of conflict in between Arduino.h & pins_Arduino.h file. I opened the pins_Arduino.h file in notepad++ tried to find out whats wrong but the contents are like huge mountains of puzzles. Still searching for the right direction.

Should I try with the 0020 version? Need to find it over internet. Official download page (http://arduino.cc/en/Main/Software (http://arduino.cc/en/Main/Software)) does not have the older versions before 1.0.

Give it a try with 1.0.1, can always go back to -0020 if it doesn't work.
avrdude.conf already has the info for atmega32.
You'll have to make a new boards.txt entry for the device.
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 27, 2013, 10:22 pm
Found something relevant... http://wiki.edwindertien.nl/doku.php?id=software:bootloaders (http://wiki.edwindertien.nl/doku.php?id=software:bootloaders)
The mod.zip file is non existent http://www.robotcraft.ca/webshop/download/zip/arduino-mega32-644-mod.zip (http://www.robotcraft.ca/webshop/download/zip/arduino-mega32-644-mod.zip)
Tried this thread too..
http://forum.arduino.cc/index.php?topic=24073.30 (http://forum.arduino.cc/index.php?topic=24073.30) (2nd post)
Still no trace of the mod file. If anyone have saved this , kindly repost the mod.
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 27, 2013, 11:21 pm
After a long search finally get the mod file from 4shared. http://www.4shared.com/get/0faTto-i/arduino-mega32-644.html (http://www.4shared.com/get/0faTto-i/arduino-mega32-644.html)
put the content in the arduino core folder & overwrote the existing files. Then tried the described step of relacing the 
Code: [Select]
#if defined(__ATmega8__) in all .c files. Unfortunately the ctrl+F cant find anything as such. & finally the arduino IDE is showing the same error report while I'm trying to upload any sketch to ATmega328p chips with either the default settings "ARVISP mkII" or "USBasp". :(
I also tried that page http://www.freetronics.com/pages/usbasp-icsp-programmer-quickstart-guide#.Ur347OLbySA for Zadig solution. No way out.
At this point I'm really perplexed. Please help.
Should I try modifying the preference.txt? I'm using Arduino IDE 1.0.5
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 28, 2013, 12:09 am
Tried Gen7
http://reprap.org/wiki/Gen7_Arduino_IDE_Support
Hopeless!
The same error with pins_arduino.h
Code: [Select]
In file included from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/Arduino.h:220,
                 from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/wiring_private.h:33,
                 from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\wiring_digital.c:28:
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:103: error: 'DDRA' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:111: error: 'PORTA' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:111: error: initializer element is not constant
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:111: error: (near initialization for 'port_to_output_PGM[1]')
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:119: error: 'PINA' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:119: error: initializer element is not constant
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:119: error: (near initialization for 'port_to_input_PGM[1]')
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 28, 2013, 12:54 am
I've read your post in this thread http://forum.arduino.cc/index.php?topic=78057.0 (3rd from bottom). I made those changes but due to that pin mapping file, the blink sketch wont even compile. Any updated repository of those configuration files? Any clue or any hints please?
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 28, 2013, 12:36 pm
Woke up & get started again to get things fixed. Found a number of threads on this topic.
Found temporary solution. https://github.com/eaconner/ATmega32-Arduino
Now my 32A is accepting the blink sketch. It is working BUT the pinmapping is...
Code: [Select]

// ATMEL ATMEGA32/32A
//
//                       +---\/---+
//           (D 0) PB0  1|        |40  PA0 (AI 0 / D24)
//           (D 1) PB1  2|        |39  PA1 (AI 1 / D25)
//      INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D26)
//       PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D27)
//       /SS (D 4) PB4  5|        |36  PA4 (AI 4 / D28)
//      MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D29)
//     /MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D30)
//      /SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D31)
//                 RST  9|        |32  AREF
//                 VCC 10|        |31  GND
//                 GND 11|        |30  AVCC
//               XTAL2 12|        |29  PC7 (D 23)
//               XTAL1 13|        |28  PC6 (D 22)
//      RX0 (D 8)  PD0 14|        |27  PC5 (D 21) TDI
//      TX0 (D 9)  PD1 15|        |26  PC4 (D 20) TDO
// RX1/INT0 (D 10) PD2 16|        |25  PC3 (D 19) TMS
// TX1/INT1 (D 11) PD3 17|        |24  PC2 (D 18) TCK
//      PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
//      PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
//          (D 14) PD6 20|        |21  PD7 (D 15) PWM
//                       +--------+
//


Then followed this thread http://forum.arduino.cc/index.php?topic=174311.15 & found the 1284 core files including Bobuino pin mapping file. https://github.com/maniacbug/mighty-1284p
Code: [Select]

// ATMEL ATMEGA1284P on Bobuino
//
//                       +---\/---+
//           (D 4) PB0 1 |        | 40 PA0 (D 21) AI 7
//           (D 5) PB1 2 |        | 39 PA1 (D 20) AI 6
//      INT2 (D 6) PB2 3 |        | 38 PA2 (D 19) AI 5
//       PWM (D 7) PB3 4 |        | 37 PA3 (D 18) AI 4
//   PWM/SS (D 10) PB4 5 |        | 36 PA4 (D 17) AI 3
//     MOSI (D 11) PB5 6 |        | 35 PA5 (D 16) AI 2
// PWM/MISO (D 12) PB6 7 |        | 34 PA6 (D 15) AI 1
//  PWM/SCK (D 13) PB7 8 |        | 33 PA7 (D 14) AI 0
//                 RST 9 |        | 32 AREF
//                VCC 10 |        | 31 GND
//                GND 11 |        | 30 AVCC
//              XTAL2 12 |        | 29 PC7 (D 29)
//              XTAL1 13 |        | 28 PC6 (D 28)
//      RX0 (D 0) PD0 14 |        | 27 PC5 (D 27) TDI
//      TX0 (D 1) PD1 15 |        | 26 PC4 (D 26) TDO
// INT0 RX1 (D 2) PD2 16 |        | 25 PC3 (D 25) TMS
// INT1 TX1 (D 3) PD3 17 |        | 24 PC2 (D 24) TCK
//     PWM (D 30) PD4 18 |        | 23 PC1 (D 23) SDA
//      PWM (D 8) PD5 19 |        | 22 PC0 (D 22) SCL
//      PWM (D 9) PD6 20 |        | 21 PD7 (D 31) PWM
//                       +--------+
//


Can't get the bobuino pin_arduino.h work with my mega32A.

Procedure Followed for mega32 pin_arduino.h:
Put the pins_arduino.h file from the downloaded directory to arduino "core" folder.
Select board > ATmega32
Programmer > USBasp
File > Upload using programmer

Yes, It works Without needing any additional core files. BUT to make life easier I found the bobuino pin mapping is the best way to use a 40 pin AVR because it already optimised the port pin numbering to a standard uno interface, like the spi, serial ports, ADC ports etc.
I am unable to port the pin configuration in pins_arduino.h, from mega32 to bobuino pin mapping. May I get any help at that stage. The mega32 & bobuino pin mapping .h files are included here.
Your guidance is highly anticipated.
Title: Re: Burning Arduino to ATmega32A
Post by: CrossRoads on Dec 28, 2013, 01:19 pm
Have you put the pins_arduino.h in the right place?
You see how both the /arduino and /mighty1284 have a bootloaders.txt, and each has a /variants and a /bootloader folder? In each /variants folder there is a board type folder with a name that matches a name from a boards.txt section, and the /bootloader folder has a folder for each board type as well with the bootloader for that card.
Set yours up the same way, under the arduino path if that is what you are using, or under the mighty1284 path.
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 28, 2013, 01:45 pm
Thanks CrossRoads, I did mistake & put the "variant" folder contents into the "core" folder. I'm going to delete the existing extracted 1.0.5 IDE & unzip it again & start from the beginning.
Title: Re: Burning Arduino to ATmega32A
Post by: CrossRoads on Dec 28, 2013, 01:59 pm
Yes, can be a little tricky. I had it worked out under -0023, maniacbug got it worked out for IDE 1.0 & later.
This is what I have for Bobuino now, fixes PCINT mapping, might need similar for Atmega32 if PCINT & Analog are same pins as 1284.

These other 2 made changes to fix INPUT_PULLUP, definition was missing.
If you are Arduino/core, check them.
If you are in mighty1284 core, replace them.

Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 28, 2013, 08:01 pm
Hello, I have followed two methods

First Method
I have put the mighty folder under "C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p" location.
Added 2 entries to boards.txt ( to the boards.txt preloaded with arduino, I did nothing with the mighty's board.txt)  [ http://forum.arduino.cc/index.php?topic=174311.15 (First post) ]
copied the mentioned optiboot .HEX files to C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\bootloaders\optiboot
Code: [Select]

##############################################################

atmega32_at16e.name=ATmega32/32A (16MHz, external)

atmega32_at16e.upload.protocol=arduino
atmega32_at16e.upload.maximum_size=32256
atmega32_at16e.upload.speed=115200

atmega32_at16e.bootloader.low_fuses=0xFF
atmega32_at16e.bootloader.high_fuses=0xD6
#make atmega32 AVR_FREQ=16000000L BAUD_RATE=115200 UART=0 LED=B7 LED_START_FLASHES=3
atmega32_at16e.bootloader.path=optiboot
atmega32_at16e.bootloader.file=optiboot_atmega32_16MHz.hex
atmega32_at16e.bootloader.unlock_bits=0x3F
atmega32_at16e.bootloader.lock_bits=0x0F

atmega32_at16e.build.mcu=atmega32
atmega32_at16e.build.f_cpu=16000000L
atmega32_at16e.build.core=mighty-1284p:standard
atmega32_at16e.build.variant=bobuino // I put the Bobuino folder to "C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\variants"

##############################################################

atmega32_at8i.name=ATmega32/32A (8MHz, internal)

atmega32_at8i.upload.protocol=arduino
atmega32_at8i.upload.maximum_size=32256
atmega32_at8i.upload.speed=57600

atmega32_at8i.bootloader.low_fuses=0xE4
atmega32_at8i.bootloader.high_fuses=0xD6
#make atmega32 AVR_FREQ=8000000L BAUD_RATE=115200 UART=0 LED=B7 LED_START_FLASHES=3
atmega32_at8i.bootloader.path=optiboot
atmega32_at8i.bootloader.file=optiboot_atmega32_8MHz.hex
atmega32_at8i.bootloader.unlock_bits=0x3F
atmega32_at8i.bootloader.lock_bits=0x0F

atmega32_at8i.build.mcu=atmega32
atmega32_at8i.build.f_cpu=8000000L
atmega32_at8i.build.core=mighty-1284p:standard
atmega32_at8i.build.variant=mega32


selected the "ATmega32/32A (16MHz, external)" board option & burnt the bootloader. It was successful.
Tools> boards> ATmega32/32A (16MHz, external)
Tools> programmers> USBasp
Tools> Burn Bootloader

Then tried to upload the blink sketch
Tools> boards> ATmega32/32A (16MHz, external)
Tools> programmers> USBasp
File> Upload Using Programmer

The error shows
Code: [Select]
In file included from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/Arduino.h:213,
                from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/wiring_private.h:33,
                from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\wiring_digital.c:28:
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/pins_arduino.h:128: error: 'PCMSK0' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/pins_arduino.h:129: error: 'PCMSK1' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/pins_arduino.h:130: error: 'PCMSK2' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/pins_arduino.h:131: error: 'PCMSK3' undeclared here (not in a function)


All the errors are regarding "PCMSK" & after googling a bit I find it out to be something related to the pinchange interrupt. Then opened the pins_arduino.h file & get this
Code: [Select]

const uint16_t __pcmsk[] =
{
 (uint16_t)&PCMSK0,
 (uint16_t)&PCMSK1,
 (uint16_t)&PCMSK2,
 (uint16_t)&PCMSK3
};

I stopped here.

Second Method
Leaving all the changes done in the first attempt untouched except restoring the Bobuino folder to "C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\variants". I put & overwrite the attached files (arduino.h, wiring_digital.c & pins_arduino.h) to the following folder "C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard"
then selected
Then tried to upload the blink sketch
Tools> boards> Bobuino
Tools> programmers> USBasp
File> Upload Using Programmer

As I am using the wrong chip (Mega32A), IDE shows error stating "Wrong microcontroller found"
Code: [Select]

Binary sketch size: 1,246 bytes (of a 130,048 byte maximum)
avrdude: Expected signature for ATMEGA1284P is 1E 97 05
        Double check chip, or use -F to override this check.

I stopped here.

I suppose I am doing something wrong with the "PCMSK" while using the bobuino pins_arduino.h with Mega32A.
Should I delete the "PCMSK" part from the bobuino pinmapping .h file?
Ummm.?

(http://img17.imageshack.us/img17/3733/9kg0.jpg)
"mighty" folder location

(http://img838.imageshack.us/img838/201/mfa1.jpg)
Board selected in the first attempt

(http://img571.imageshack.us/img571/8647/njfy.jpg)
Board selected in the second attempt.

I can successfully upload sketches to Mega32A using the mega32 core files but I have to compromise with the pinmappings, I guess in that case I have to alter all the pin configurations for every arduino library. On the other hand bobuino features all  the pin numbers including the spi, i2c, uart, adc etc. in a standard manner that will make the use of arduino libraries less complicated. That's why I want to alter the pin mappings in my mega32A.
Title: Re: Burning Arduino to ATmega32A
Post by: CrossRoads on Dec 28, 2013, 08:37 pm
You're definitely on the right track, keep at it.
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 28, 2013, 10:14 pm
Thanks a million times CrossRoads for the support & motivation throughout the experiment. Aaaahhhh... what a relief! I just commented out the "PCMSK" part of the pins_arduino.h file & the blink sketch works. I tried different pins & it works as desired.
I deleted the "mighty" folders completely & changed the core directory to "arduino", this pin mapping works with that too without any additional core files. Can't I use the interrupt feature in the mega32A chip? Will there be any problem while using the UART & other protocols with that setup? Should I have to add some other files to make these things work? I'm asking this because the new pin mapping works without any additional arduino.h, wiring_digital.c files. Any suggestions?

I'm using the optiboot_atmega32_16MHz.hex bootloader file. Tomorrow I'll try to upload sketches on the mega32 without using the bootloader so that I can use full 32kb space.
Once again, thanks a lot CrossRoads.
:)
Title: Re: Burning Arduino to ATmega32A
Post by: CrossRoads on Dec 29, 2013, 12:59 am
I don't know, try things & see what works or doesn't. Add things back in as needed.  Good luck!
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 29, 2013, 07:14 pm
Successfully uploaded sketches to the mega32A(with bobuino pin mapping) without using bootloader.
Now the next step is to implement the "playing tones based on micros()" project. Excited
:)
Title: Re: Burning Arduino to ATmega32A
Post by: CrossRoads on Dec 29, 2013, 07:33 pm
So you're just using File:Upload Using Programmer then and things are working ok? Cool.
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 29, 2013, 07:46 pm
Yes, it is really working fine. saw some tutorials that said to edit the preference.txt file for changing the upload protocol to "USBasp". I just wanted to see what happens if I don't use the edit method. In the first attempt it worked!

Procedure followed:

Connected the chip to the computer with Usbasp programmer.
Added 16MHz crystal
opened "extremeburner" software (avrdude gui)
Selected the proper chip from chip settings
hit the "chip erase" option
then opened the arduino.exe
opened the blink sketch & changed the pin number to 31 to check both pin mapping & upload.
board & programmer setting are same as the first attempt settings
then hit "upload using programmer"
the sketch uploaded
I checked again with pin number 12 & trust me it worked!
:o
Title: Re: Burning Arduino to ATmega32A
Post by: CrossRoads on Dec 29, 2013, 08:06 pm
How did you set the fuses?
Section 26 of the datasheet
http://www.atmel.com/Images/Atmel-8155-8-bit-Microcontroller-AVR-ATmega32A_Datasheet.pdf
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 29, 2013, 09:30 pm
I suppose the issue is with the lock bits. According to this discussion ( http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=59549 (http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=59549) ), the "chip erase" function doesn't remove the fuse bits. But erases all the flash and lock bits if they are set, as well as EEPROM. 
I didn't reconfigured the fusebits for using the mega32 without bootloader, the fusebits were already set to require 16MHz external crystal when I uploaded the arduino bootloader. I think this the explanation of such behaviour of mega32. Please correct me if I'm getting it wrong.

The boards.txt content is this...
Code: [Select]

##############################################################

atmega32_at16e.name=ATmega32/32A (16MHz, external)

atmega32_at16e.upload.protocol=arduino
atmega32_at16e.upload.maximum_size=32256
atmega32_at16e.upload.speed=115200

atmega32_at16e.bootloader.low_fuses=0xFF
atmega32_at16e.bootloader.high_fuses=0xD6
#make atmega32 AVR_FREQ=8000000L BAUD_RATE=115200 UART=0 LED=B7 LED_START_FLASHES=3
atmega32_at16e.bootloader.path=optiboot
atmega32_at16e.bootloader.file=optiboot_atmega32_16MHz.hex
atmega32_at16e.bootloader.unlock_bits=0x3F
atmega32_at16e.bootloader.lock_bits=0x0F

atmega32_at16e.build.mcu=atmega32
atmega32_at16e.build.f_cpu=16000000L
atmega32_at16e.build.core=arduino
atmega32_at16e.build.variant=mega32

##############################################################

But the last post of the avrfreaks.com discussion put me in puzzle!

(http://img809.imageshack.us/img809/2088/isr3.jpg)
After doing a "Chip Erase" uploaded the blink sketch. Pin 12

(http://img593.imageshack.us/img593/4571/xrqb.jpg)
After the chiperase I read the fusebits in the gui. The lock bits are changed.
Now this is getting mysterious. What is actually happening there? Can't get it.
Any tweaks on how to check if there is any bootloader in the chip?
Title: Re: Burning Arduino to ATmega32A
Post by: CrossRoads on Dec 29, 2013, 09:39 pm
The Extended, High, Low, and Lock bits may read back as 1 if they do not exist, don't be confused by non-existent bits.
Title: Re: Burning Arduino to ATmega32A
Post by: nightcrawler218 on Dec 29, 2013, 11:48 pm
After burning the arduino bootloader the "lock bits" are set to 0X0F
0X0F = 0000 1111
lock bits.........  7  6  5  4  3  2  1  0
bits allocated (-  -) 0  0  1   1  1  1
it should be     1   1  0  0  1   1   1  1 = 0XCF

But according to the datasheet, bits 6 & 7 are non-existent & default value is "1"
so the lockbit should be 1100 1111 or 0XCF. But in practice it is 0X0F. what is the reason?
(http://img12.imageshack.us/img12/8204/guzb.jpg)

What are the "Unlock bits"? Found a thread http://forum.arduino.cc/index.php?topic=23577.0 (http://forum.arduino.cc/index.php?topic=23577.0). I quote
Quote

What error do you get? 

The "unlock" bits are just the value that's written to the lock bits before burning the bootloader.  Then the "lock" bits are written after burning the bootloader.

So, what is the significance of using the unlock bits in arduino?
Title: Re: Burning Arduino to ATmega32A
Post by: vishalvcp on Aug 26, 2016, 03:26 pm
hello friends i am using arduino1.6.8 version and trying to program atmega32a using usbasp, i tried to blink on each port pin, in these few port pin blinks( i am using openharware board atmega16) but few port pins dont work, i ried same program on proteus and it works fine there. i read some articles and i found that maybe that open hardware board is for atmega32 not atmega32a but i am not sure please help me out
Title: Re: Burning Arduino to ATmega32A
Post by: pert on Aug 26, 2016, 04:44 pm
The ATmega32 and ATmega32A have the same pinout and IO configuration. The only differences I'm aware of are the operating voltage and power consumption specs(see datasheets for details).

Which hardware definitions are you using? I recommend MightyCore(https://github.com/MCUdude/MightyCore (https://github.com/MCUdude/MightyCore)). It supports ATmega32 as well as a bunch of other parts. It doesn't specifically support ATmega32A but that's fine because ATmega32 and 32A have the same signature. I've tried it with an ATmega32A and it works fine. The only problem you'll encounter with using it is if you have some code that relies on the __AVR_ATmega32A__ macro since the __AVR_ATmega32__ macro will be defined instead.
Title: Re: Burning Arduino to ATmega32A
Post by: hansibull on Aug 26, 2016, 09:22 pm
There's no difference between the ATmega32 and the ATmega32A except the operating voltage current draw and a few minor things. Have a look at the AVR521 (http://www.atmel.com/images/doc8162.pdf) document for more info. I've done all the MightyCore testing on an ATmega32A.

Quote
The only problem you'll encounter with using it is if you have some code that relies on the __AVR_ATmega32A__ macro since the __AVR_ATmega32__ macro will be defined instead.
Actually, I've no idea where the __AVR_megaXX__ is located. I've curious to find out if there even exist such a definition as __AVR_ATmega32A__. When I developed this core I used this device signature list (http://www.avrfreaks.net/comment/821330#comment-821330) to make sure all variants was included. Note that the ATmega324A, P and PA all have different device signatures! That's why I've included all three options in the boards manager menu ;)
Title: Re: Burning Arduino to ATmega32A
Post by: pert on Aug 26, 2016, 09:45 pm
Actually, I've no idea where the __AVR_megaXX__ is located.
I did a search of the Arduino AVR Boards tools folder and only found in hardware/tools/avr/lib/gcc/avr/4.9.2/device-specs/specs-atmega32a lines 93-94:
Code: [Select]
*cpp:
 -D__AVR_ATmega32A__ -D__AVR_DEVICE_NAME__=atmega32a


I've curious to find out if there even exist such a definition as __AVR_ATmega32A__.
If you make a boards.txt entry with the line build.mcu=atmega32a the macro will indeed be defined. Unfortunately there's no entry for it in avrdude.conf so you have to add one and deal with the hassle of a custom programmer for upload.

When I developed this core I used this device signature list (http://www.avrfreaks.net/comment/821330#comment-821330) to make sure all variants was included.
I use this one http://www.atmel.com/webdoc/AVRLibcReferenceManual/using_tools_1using_avr_gcc_mach_opt.html (http://www.atmel.com/webdoc/AVRLibcReferenceManual/using_tools_1using_avr_gcc_mach_opt.html), seems more official. Note that they do have __AVR_ATmega32A__ listed.