ATMEGA32A ardunio
本帖最后由 jamehk 于 2015-9-13 07:37 编辑IDE:ardunio1.6.3
ISP:usbasp
Burning Arduino to ATmega32A (Read 10852 times)
烧写步骤:
1、修改 boards.txt
路径:C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt
找到 atmegang.name=Arduino NG or older 部分,并在 ## Arduino NG or older w/ ATmega8 部分的后面 增加以下部分内容
## Arduino NG or older w/ ATmega32
## -------------------------
atmegang.menu.cpu.atmega32=ATmega32
atmegang.menu.cpu.atmega32.bootloader.tool=avrdude_anders
atmegang.menu.cpu.atmega32.upload.protocol=arduino
atmegang.menu.cpu.atmega32.upload.maximum_size=28336
atmegang.menu.cpu.atmega32.upload.speed=57600
atmegang.menu.cpu.atmega32.bootloader.low_fuses=0xff
atmegang.menu.cpu.atmega32.bootloader.high_fuses=0xdd
atmegang.menu.cpu.atmega32.bootloader.extended_fuses=0x00
atmegang.menu.cpu.atmega32.bootloader.file=atmega32/ATmegaBOOT_32.hex
atmegang.menu.cpu.atmega32.build.mcu=atmega32
atmegang.menu.cpu.atmega32.build.board=AVR_MEGA
2、修改platform.txt,增加自定义的 avrdude_anders
打开C:\Program Files (x86)\Arduino\hardware\arduino\avr\platform.txt
找到 ”AVR Uploader/Programmers tools“ 部分,内容如下:
# AVR Uploader/Programmers tools
# ------------------------------
tools.avrdude.path={runtime.tools.avrdude.path}
tools.avrdude.cmd.path={path}/bin/avrdude
tools.avrdude.config.path={path}/etc/avrdude.conf
tools.avrdude.upload.params.verbose=-v
tools.avrdude.upload.params.quiet=-q -q
tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"
tools.avrdude.program.params.verbose=-v
tools.avrdude.program.params.quiet=-q -q
tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
tools.avrdude.erase.params.verbose=-v
tools.avrdude.erase.params.quiet=-q -q
tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m
tools.avrdude.bootloader.params.verbose=-v
tools.avrdude.bootloader.params.quiet=-q -q
tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m
在这段后面 增加如下内容:
# AVR Uploader/Programmers tools and by anders 2015.08.30
# ------------------------------
tools.avrdude_anders.path={runtime.tools.avrdude.path}
tools.avrdude_anders.cmd.path={path}/bin/avrdude
tools.avrdude_anders.config.path={path}/etc/avrdude.conf
tools.avrdude_anders.upload.params.verbose=-v
tools.avrdude_anders.upload.params.quiet=-q -q
tools.avrdude_anders.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"
tools.avrdude_anders.program.params.verbose=-v
tools.avrdude_anders.program.params.quiet=-q -q
tools.avrdude_anders.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
#this line was edited by anders 2015.08.30
tools.avrdude_anders.erase.params.verbose=-v
tools.avrdude_anders.erase.params.quiet=-q -q
tools.avrdude_anders.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m-Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m
tools.avrdude_anders.bootloader.params.verbose=-v
tools.avrdude_anders.bootloader.params.quiet=-q -q
tools.avrdude_anders.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m
3、放置 ATmegaBOOT_32.hex
在C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders 下增加 atmega32 目录,并将附件里面的
ATmegaBOOT_32.hex 拷贝到该目录下
4、烧录
打开ardunio1.6.3 工具菜单,板:选择 Arduino NG or older ,处理器选择:ATmega32即可
温馨提醒:说明如果此处 bootloader.tool 使用默认的 avrdude ,会报 "efuse" memory type not defined for part "ATmega32" 错误
参见:
https://github.com/arduino/Arduino/issues/2075#issuecomment-69155718
Write bootloader - problem on ATmega8
5.忘了提醒,需要在 hardware\arduino\avr\variants 增加 mega32 目录 并放置 附件的 pins_arduino.h
好贴标记一下…… 谢谢 楼主的无私奉献,能讲一下atmega16,如何添加进来吗? 顶起,继续呼唤楼主,解决atmega16的问题! cciew 发表于 2015-9-7 18:58 static/image/common/back.gif
顶起,继续呼唤楼主,解决atmega16的问题!
mega16 是一样的啊,
##############################################################
mega16.name=Custom AVR's As Arduino
mega16.upload.tool=avrdude
mega16.upload.protocol=arduino
mega16.bootloader.tool=avrdude
mega16.bootloader.unlock_bits=0x3F
mega16.bootloader.lock_bits=0x0F
mega16.bootloader.file=
mega16.build.f_cpu=16000000L
mega16.build.board=AVR_MEGA16
mega16.build.core=arduino
## Arduino ATmega16
## ---------------------------------------------
mega16.menu.cpu.atmega16=ATmega16
mega16.menu.cpu.atmega16.upload.maximum_size=16384
mega16.menu.cpu.atmega16.upload.maximum_data_size=1024
mega16.menu.cpu.atmega16.upload.speed=115200
mega16.menu.cpu.atmega16.bootloader.low_fuses=0xFF
mega16.menu.cpu.atmega16.bootloader.high_fuses=0xDE
mega16.menu.cpu.atmega16.build.mcu=atmega16
mega16.menu.cpu.atmega16.build.variant=mega16
jamehk 发表于 2015-9-9 16:37 static/image/common/back.gif
mega16 是一样的啊,
##############################################################
芯片可以选择了,但是编译错误! cciew 发表于 2015-9-9 20:35 static/image/common/back.gif
芯片可以选择了,但是编译错误!
你忘了 在 arduino\avr\variants\ 目录下 增加mega16目录,并要拷贝一个pins_arduino.h mega32 和 MEGA16 都可以使用的 pins_arduino.h
晕,不知道怎么上传附件#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#include <avr/pgmspace.h>
// ATMEGA16/32
//
// +---\/---+
// (D 0) PB01| |40PA0 (AI 0 / D31)
// (D 1) PB12| |39PA1 (AI 1 / D30)
// INT2 (D 2) PB23| |38PA2 (AI 2 / D29)
// PWM (D 3) PB34| |37PA3 (AI 3 / D28)
// PWM/SS (D 4) PB45| |36PA4 (AI 4 / D27)
// MOSI (D 5) PB56| |35PA5 (AI 5 / D26)
//PWM/MISO (D 6) PB67| |34PA6 (AI 6 / D25)
// PWM/SCK (D 7) PB78| |33PA7 (AI 7 / D24)
// RST9| |32AREF
// VCC 10| |31GND
// GND 11| |30AVCC
// XTAL2 12| |29PC7 (D 23)
// XTAL1 13| |28PC6 (D 22)
// RX0 (D 8)PD0 14| |27PC5 (D 21) TDI
// TX0 (D 9)PD1 15| |26PC4 (D 20) TDO
// RX1/INT0 (D 10) PD2 16| |25PC3 (D 19) TMS
// TX1/INT1 (D 11) PD3 17| |24PC2 (D 18) TCK
// PWM (D 12) PD4 18| |23PC1 (D 17) SDA
// PWM (D 13) PD5 19| |22PC0 (D 16) SCL
// (D 14) PD6 20| |21PD7 (D 15) PWM
// +--------+
//
#define NUM_DIGITAL_PINS 32
#define NUM_ANALOG_INPUTS 8
#define analogInputToDigitalPin(p)((p < NUM_ANALOG_INPUTS) ? (p) + 24 : -1)
//#define digitalPinHasPWM(p) ((p) == 3 || (p) == 12 || (p) == 13 || (p) == 15)
#define digitalPinHasPWM(p) ((p) == 12 || (p) == 13 || (p) == 15)
static const uint8_t SS = 4;
static const uint8_t MOSI = 5;
static const uint8_t MISO = 6;
static const uint8_t SCK= 7;
static const uint8_t SDA = 17;
static const uint8_t SCL = 16;
#define LED_BUILTIN 7
static const uint8_t OC1B = 12;
static const uint8_t JA0 = 31;
static const uint8_t JA1 = 30;
static const uint8_t JA2 = 29;
static const uint8_t JA3 = 28;
static const uint8_t JA4 = 27;
static const uint8_t JA5 = 26;
static const uint8_t JA6 = 25;
static const uint8_t JA7 = 24;
static const uint8_t JB0 = 0;
static const uint8_t JB1 = 1;
static const uint8_t JB2 = 2;
static const uint8_t JB3 = 3;
static const uint8_t JB4 = 4;
static const uint8_t JB5 = 5;
static const uint8_t JB6 = 6;
static const uint8_t JB7 = 7;
static const uint8_t JC0 = 16;
static const uint8_t JC1 = 17;
static const uint8_t JC2 = 18;
static const uint8_t JC3 = 19;
static const uint8_t JC4 = 20;
static const uint8_t JC5 = 21;
static const uint8_t JC6 = 22;
static const uint8_t JC7 = 23;
static const uint8_t JD0 = 8;
static const uint8_t JD1 = 9;
static const uint8_t JD2 = 10;
static const uint8_t JD3 = 11;
static const uint8_t JD4 = 12;
static const uint8_t JD5 = 13;
static const uint8_t JD6 = 14;
static const uint8_t JD7 = 15;
//#define digitalPinToPCICR(p) (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (&PCICR) : ((uint8_t *)0))
//#define digitalPinToPCICRbit(p) (((p) <= 7) ? 1 : (((p) <= 15) ? 3 : (((p) <= 23) ? 2 : 0)))
//#define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))
//#define digitalPinToPCMSKbit(p) ((p) % 8)
#define digitalPinToInterrupt(p) ((p) == 10 ? 0 : ((p) == 11 ? 1 : ((p) == 2 ? 2 : NOT_AN_INTERRUPT)))
#ifdef ARDUINO_MAIN
const uint16_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
(uint16_t) &DDRA,
(uint16_t) &DDRB,
(uint16_t) &DDRC,
(uint16_t) &DDRD,
};
const uint16_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
(uint16_t) &PORTA,
(uint16_t) &PORTB,
(uint16_t) &PORTC,
(uint16_t) &PORTD,
};
const uint16_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PORT,
(uint16_t) &PINA,
(uint16_t) &PINB,
(uint16_t) &PINC,
(uint16_t) &PIND,
};
const uint8_t PROGMEM digital_pin_to_port_PGM = {
PB,// PB0 ** D0
PB,// PB1 ** D1
PB,// PB2 ** D2
PB,// PB3 ** D3
PB,// PB4 ** D4
PB,// PB5 ** D5
PB,// PB6 ** D6
PB,// PB7 ** D7
PD,// PD0 ** D8
PD,// PD1 ** D9
PD,// PD2 ** D10
PD,// PD3 ** D11
PD,// PD4 ** D12
PD,// PD5 ** D13
PD,// PD6 ** D14
PD,// PD7 ** D15
PC,// PC0 ** D16
PC,// PC1 ** D17
PC,// PC2 ** D18
PC,// PC3 ** D19
PC,// PC4 ** D20
PC,// PC5 ** D21
PC,// PC6 ** D22
PC,// PC7 ** D23
PA,// PA7 ** A7 D24
PA,// PA6 ** A6 D25
PA,// PA5 ** A5 D26
PA,// PA4 ** A4 D27
PA,// PA3 ** A3 D28
PA,// PA2 ** A2 D29
PA,// PA1 ** A1 D30
PA,// PA0 ** A0 D31
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM = {
_BV(0),// PB0 ** D0
_BV(1),// PB1 ** D1
_BV(2),// PB2 ** D2
_BV(3),// PB3 ** D3
_BV(4),// PB4 ** D4
_BV(5),// PB5 ** D5
_BV(6),// PB6 ** D6
_BV(7),// PB7 ** D7
_BV(0),// PD0 ** D8
_BV(1),// PD1 ** D9
_BV(2),// PD2 ** D10
_BV(3),// PD3 ** D11
_BV(4),// PD4 ** D12
_BV(5),// PD5 ** D13
_BV(6),// PD6 ** D14
_BV(7),// PD7 ** D15
_BV(0),// PC0 ** D16
_BV(1),// PC1 ** D17
_BV(2),// PC2 ** D18
_BV(3),// PC3 ** D19
_BV(4),// PC4 ** D20
_BV(5),// PC5 ** D21
_BV(6),// PC6 ** D22
_BV(7),// PC7 ** D23
_BV(7),// PA7 ** A7 D24
_BV(6),// PA6 ** A6 D25
_BV(5),// PA5 ** A5 D26
_BV(4),// PA4 ** A4 D27
_BV(3),// PA3 ** A3 D28
_BV(2),// PA2 ** A2 D29
_BV(1),// PA1 ** A1 D30
_BV(0),// PA0 ** A0 D31
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
NOT_ON_TIMER, /* 0- PB0 */
NOT_ON_TIMER, /* 1- PB1 */
NOT_ON_TIMER, /* 2- PB2 */
TIMER0A, /* 3- PB3 */
//TIMER0, /* 3- PB3 */
NOT_ON_TIMER, /* 4- PB4 */
NOT_ON_TIMER, /* 5- PB5 */
NOT_ON_TIMER, /* 6- PB6 */
NOT_ON_TIMER, /* 7- PB7 */
NOT_ON_TIMER, /* 8- PD0 */
NOT_ON_TIMER, /* 9- PD1 */
NOT_ON_TIMER, /* 10 - PD2 */
NOT_ON_TIMER, /* 11 - PD3 */
TIMER1B, /* 12 - PD4 */
TIMER1A, /* 13 - PD5 */
NOT_ON_TIMER, /* 14 - PD6 */
TIMER2, /* 15 - PD7 */
NOT_ON_TIMER, /* 16 - PC0 */
NOT_ON_TIMER, /* 17 - PC1 */
NOT_ON_TIMER, /* 18 - PC2 */
NOT_ON_TIMER, /* 19 - PC3 */
NOT_ON_TIMER, /* 20 - PC4 */
NOT_ON_TIMER, /* 21 - PC5 */
NOT_ON_TIMER, /* 22 - PC6 */
NOT_ON_TIMER, /* 23 - PC7 */
NOT_ON_TIMER, /* 24 - PA7 */
NOT_ON_TIMER, /* 25 - PA6 */
NOT_ON_TIMER, /* 26 - PA5 */
NOT_ON_TIMER, /* 27 - PA4 */
NOT_ON_TIMER, /* 28 - PA3 */
NOT_ON_TIMER, /* 29 - PA2 */
NOT_ON_TIMER, /* 30 - PA1 */
NOT_ON_TIMER/* 31 - PA0 */
};
#endif
// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use.For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPENHardware serial ports which are open for use.Their RX & TX
// pins are NOT connected to anything by default.
#define SERIAL_PORT_MONITOR Serial
#define SERIAL_PORT_HARDWARESerial
#endif 谢谢了,有时间试试!
页:
[1]