Go Down

Topic: Program Atmega16 using Arduino (Read 6744 times) previous topic - next topic

undefined

Apr 06, 2010, 01:44 pm Last Edit: Apr 07, 2010, 03:01 am by undefined Reason: 1
I'm using arduino-0018.

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

Thanks.

undefined

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: [Select]

#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: [Select]

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

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.

Groove

Quote
Can't pass the compile


What error does it give?
Per Arduino ad Astra

undefined

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)

Groove

#4
Apr 07, 2010, 01:49 pm Last Edit: Apr 07, 2010, 02:04 pm by GrooveFlotilla Reason: 1
That's correct - the ATMega16 doesn't have either EICRA or EIMSK.
http://www.atmel.com/dyn/resources/prod_documents/doc2466.pdf
Per Arduino ad Astra

undefined

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

Groove

#6
Apr 07, 2010, 04:02 pm Last Edit: Apr 07, 2010, 04:03 pm by GrooveFlotilla Reason: 1
You may get away with just modifying "WInterrupts.c" where EICRA is defined as MCUCR and EIMSK as GICR for the ATmega8.
Per Arduino ad Astra

Ehab

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


Ehab

I used the parallel programmer and it work fine


how can I attach files here ??

kevos

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.

Coding Badly


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

...ATmega16 is listed as working.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy