Pages: [1]   Go Down
Author Topic: Program Atmega16 using Arduino  (Read 5884 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
*
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using arduino-0018.

Anyone knows what should i do to let me program Atmega16 using Arduino(0018)?

Thanks.
« Last Edit: April 06, 2010, 08:01:08 pm by undefined » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
*
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Up to now,follow http://www.subtours.com/ralph/theory/atmega16witharduino.html this article,i'v modified pins_arduino.c in arduino-0018\hardware\arduino\cores\arduino\

added

Code:
#elif defined(__AVR_ATmega16__)
const uint16_t PROGMEM port_to_mode_PGM[] = {
      NOT_A_PORT,
      &DDRA,
      &DDRB,
      &DDRC,
      &DDRD,
};

const uint16_t PROGMEM port_to_output_PGM[] = {
      NOT_A_PORT,
      &PORTA,
      &PORTB,
      &PORTC,
      &PORTD,
};

const uint16_t PROGMEM port_to_input_PGM[] = {
      NOT_A_PIN,
      &PINA,
      &PINB,
      &PINC,
      &PIND,
};

const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
      // PORTLIST
      PD, /* 0 */
      PD,
      PD,
      PD,
      PD,
      PD,
      PD,
      PD,
      PB, /* 8 */
      PB,
      PB,
      PB,
      PB,
      PB,
      PC, /* 14 */
      PC,
      PC,
      PC,
      PC,
      PC,
      PC,
      PC,
      PA,/* 22*/
      PA,
      PA,
      PA,
      PA,
      PA,
      PA,
      PA,
};

const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
      // PIN IN PORT
      // -------------------------------------------
      _BV(0), /* 0, port D */
      _BV(1),
      _BV(2),
      _BV(3),
      _BV(4),
      _BV(5),
      _BV(6),
      _BV(7),
      _BV(0), /* 8, port B */
      _BV(1),
      _BV(2),
      _BV(3),
      _BV(4),
      _BV(5),
      _BV(0), /* 14, port C */
      _BV(1),
      _BV(2),
      _BV(3),
      _BV(4),
      _BV(5),
      _BV(6),
      _BV(7),
      _BV(0), /* 22, port A */
      _BV(1),
      _BV(2),
      _BV(3),
      _BV(4),
      _BV(5),
      _BV(6),
      _BV(7),
};

const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
      // TIMERS
      // -------------------------------------------
      NOT_ON_TIMER, /* 0 - port D */
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      TIMER1B,
      TIMER1A,
      NOT_ON_TIMER,
      TIMER2,
      NOT_ON_TIMER, /* 8 - port B */
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,/* 14 - port C */
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER, /*22 port A */
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
      NOT_ON_TIMER,
};

boards.txt in arduino-0018\hardware\arduino

added

Code:
##############################################################

atmega16.name=The mega16 w/ ATmega16

atmega16.upload.protocol=stk500
atmega16.upload.maximum_size=7168
atmega16.upload.speed=19200

atmega16.bootloader.low_fuses=0xdf
atmega16.bootloader.high_fuses=0xca
atmega16.bootloader.path=atmega8
atmega16.bootloader.file=ATmegaBOOT.hex
atmega16.bootloader.unlock_bits=0x3F
atmega16.bootloader.lock_bits=0x0F

atmega16.build.mcu=atmega16
atmega16.build.f_cpu=16000000L
atmega16.build.core=arduino

Can't pass the compile...
Can anyone give me some advice on what i need to do?

Thank you very much.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Can't pass the compile

What error does it give?
Logged

Per Arduino ad Astra

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
*
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

D:\arduino-0018\hardware\arduino\cores\arduino\WInterrupts.c: In function 'attachInterrupt':

D:\arduino-0018\hardware\arduino\cores\arduino\WInterrupts.c:90: error: 'EICRA' undeclared (first use in this function)

D:\arduino-0018\hardware\arduino\cores\arduino\WInterrupts.c:90: error: (Each undeclared identifier is reported only once

D:\arduino-0018\hardware\arduino\cores\arduino\WInterrupts.c:90: error: for each function it appears in.)

D:\arduino-0018\hardware\arduino\cores\arduino\WInterrupts.c:91: error: 'EIMSK' undeclared (first use in this function)

D:\arduino-0018\hardware\arduino\cores\arduino\WInterrupts.c: In function 'detachInterrupt':

D:\arduino-0018\hardware\arduino\cores\arduino\WInterrupts.c:135: error: 'EIMSK' undeclared (first use in this function)
Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's correct - the ATMega16 doesn't have either EICRA or EIMSK.
http://www.atmel.com/dyn/resources/prod_documents/doc2466.pdf
« Last Edit: April 07, 2010, 07:04:29 am by GrooveFlotilla » Logged

Per Arduino ad Astra

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
*
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so which file should i modify to make it work?
WInterrupts.c or there is another file made this happen?
Thanks.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You may get away with just modifying "WInterrupts.c" where EICRA is defined as MCUCR and EIMSK as GICR for the ATmega8.
« Last Edit: April 07, 2010, 09:03:44 am by GrooveFlotilla » Logged

Per Arduino ad Astra

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I modify all the necessary files and pass the compile but I con not
down load the hex to the mcu


avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I used the parallel programmer and it work fine


how can I attach files here ??
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm currently working on a Sure-Electronics ATMEGA16 based board and would like to run Arduino on it. Could you post the files you've changed onto this forum please? I'd be very grateful.
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 206
Posts: 12859
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


http://www.arduino-avr.com/

...ATmega16 is listed as working.
Logged

Pages: [1]   Go Up
Jump to: