Go Down

Topic: uploading a sketch atmega16 using arduino IDE (Read 1 time) previous topic - next topic

visasimbu

Hi Team,
I am new to arduino IDE & IoT. I am using arduino IDE - 1.8.4 software.

My aim is to upload the blink program to ATMega16. I have used USBasp to upload the program to ATmega16. I fetched sample program from File->AVR C code Examples -> blink. This program uploaded using avrdude commands without any issues in my atmega16. This worked as well. Created hex files in arduino by compiling and then uploaded using below avr commands in command prompt. This ensures that my connections and chip is working fine without any issues.

Code: [Select]
avrdude -CF:\SIMBU\IoT\MyPrograms\AVRISP\Attempt5\avrdude\etc\avrdude.conf -c usbasp -p ATmega16 -Uflash:w:F:\SIMBU\IoT\MyPrograms\AVRISP\Attempt5\HEXFiles/Blink.ino.hex:i -B10


I like to use arduino program like using simple keywords (digitalWrite etc., ) instead of the C code. Hence I have installed MightyCore (since this is the one I got in google to install ATmega16) in my preferences.

Code: [Select]
https://mcudude.github.io/MightyCore/package_MCUdude_MightyCore_index.json

Issue is my blink program in Arudino language is not working. I have followed below steps.

1) Choosed Tools ->Boards -> ATmega16(mightycore) and programmer as USBasp.
2) Clicked upload button without connecting USBasp to my computer to create the hex file.
3) Then this hex file was used to upload into ATmega16 using command prompt avrdude commands. Now my blinking program didn't work. I am not sure what I have missed here.

I have ended up with few queries.
1) Which digital pin connected with which pin of ATmega 16 ? - Note - I tried plug in my led to all the pinout of Atmega16

Kindly help me on this issue. Advance thanks

My code

Code: [Select]
void setup() {
  pinMode(6, OUTPUT);
}

void loop() {
  digitalWrite(6, HIGH);   
  delay(1000);                       
  digitalWrite(6, LOW);   
  delay(1000);                       
}

pert

1) Which digital pin connected with which pin of ATmega 16 ?
It depends on your Tools > Pinout selection. You can find pin mapping diagrams for each of the pinout options here:
https://github.com/MCUdude/MightyCore#pinout
Click on the relevant image to see it larger. The numbers with the blue background are the Arduino pin numbers.

visasimbu

I am receiving below error when I clicked burn bootloader in Arduino IDE. But I am able to upload program using avrdude commands. What went wrong when I use arduino IDE ?

Code: [Select]
Arduino: 1.8.4 (Windows 10), Board: "ATmega16, Standard, 2.7v, Disabled (default), 1 MHz internal"

C:\Users\kavig.LAPTOP-2AR9L79K\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/bin/avrdude -CC:\Users\kavig.LAPTOP-2AR9L79K\AppData\Local\Arduino15\packages\MightyCore\hardware\avr\1.0.8/avrdude.conf -v -patmega16 -cusbasp -Pusb -e -Ulock:w:0x3f:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:0xd4:m -Ulfuse:w:0b10100001:m

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\kavig.LAPTOP-2AR9L79K\AppData\Local\Arduino15\packages\MightyCore\hardware\avr\1.0.8/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbasp
         AVR Part                      : ATmega16
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom         4    10   128    0 no        512    4      0  9000  9000 0xff 0xff
           flash         33     6   128    0 yes     16384  128    128  4500  4500 0xff 0xff
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          0    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

Error while burning bootloader.

kprims

Try shorting JP3  on the Usbasp for slow SCK which should work for your 1MHz  internal clock.

visasimbu

Thanks everyone.

I found the root cause of my issue. Somehow i have set external clock spead as 16 Mhz instead of internal 8Mhz or 1 Mhz. This made my chip to listen only 16 Mhz. I was using ATMega16 with 8 Mhz internal clock speed.

So I have purchased crystal 16 Mhz (XTAL) and connected between XTAL2 and XTAL1.

Then I have tried uploading program by using setting internal clock speed of 1Mhz. This worked for me.

Go Up