极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 15406|回复: 8

ATMEGA32A ardunio

[复制链接]
发表于 2015-8-30 18:39:22 | 显示全部楼层 |阅读模式
本帖最后由 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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2015-8-31 00:14:47 来自手机 | 显示全部楼层
好贴标记一下……
回复 支持 反对

使用道具 举报

发表于 2015-8-31 22:10:08 | 显示全部楼层
谢谢 楼主的无私奉献,能讲一下atmega16,如何添加进来吗?
回复 支持 反对

使用道具 举报

发表于 2015-9-7 18:58:06 | 显示全部楼层
顶起,继续呼唤楼主,解决atmega16的问题!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-9-9 16:37:10 | 显示全部楼层
cciew 发表于 2015-9-7 18:58
顶起,继续呼唤楼主,解决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
回复 支持 反对

使用道具 举报

发表于 2015-9-9 20:35:50 | 显示全部楼层
jamehk 发表于 2015-9-9 16:37
mega16 是一样的啊,

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

芯片可以选择了,但是编译错误!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-9-13 07:34:22 | 显示全部楼层
cciew 发表于 2015-9-9 20:35
芯片可以选择了,但是编译错误!

你忘了 在 arduino\avr\variants\ 目录下 增加mega16目录,并要拷贝一个pins_arduino.h
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-9-13 07:41:19 | 显示全部楼层
mega32 和 MEGA16 都可以使用的 pins_arduino.h

晕,不知道怎么上传附件
  1. #ifndef Pins_Arduino_h
  2. #define Pins_Arduino_h

  3. #include <avr/pgmspace.h>

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

  29. #define NUM_DIGITAL_PINS            32
  30. #define NUM_ANALOG_INPUTS           8
  31. #define analogInputToDigitalPin(p)  ((p < NUM_ANALOG_INPUTS) ? (p) + 24 : -1)
  32. //#define digitalPinHasPWM(p)         ((p) == 3 || (p) == 12 || (p) == 13 || (p) == 15)
  33. #define digitalPinHasPWM(p)         ((p) == 12 || (p) == 13 || (p) == 15)


  34. static const uint8_t SS   = 4;
  35. static const uint8_t MOSI = 5;
  36. static const uint8_t MISO = 6;
  37. static const uint8_t SCK  = 7;

  38. static const uint8_t SDA = 17;
  39. static const uint8_t SCL = 16;

  40. #define LED_BUILTIN 7

  41. static const uint8_t OC1B = 12;

  42. static const uint8_t JA0 = 31;
  43. static const uint8_t JA1 = 30;
  44. static const uint8_t JA2 = 29;
  45. static const uint8_t JA3 = 28;
  46. static const uint8_t JA4 = 27;
  47. static const uint8_t JA5 = 26;
  48. static const uint8_t JA6 = 25;
  49. static const uint8_t JA7 = 24;
  50.                      
  51. static const uint8_t JB0 = 0;
  52. static const uint8_t JB1 = 1;
  53. static const uint8_t JB2 = 2;
  54. static const uint8_t JB3 = 3;
  55. static const uint8_t JB4 = 4;
  56. static const uint8_t JB5 = 5;
  57. static const uint8_t JB6 = 6;
  58. static const uint8_t JB7 = 7;
  59.                      
  60. static const uint8_t JC0 = 16;
  61. static const uint8_t JC1 = 17;
  62. static const uint8_t JC2 = 18;
  63. static const uint8_t JC3 = 19;
  64. static const uint8_t JC4 = 20;
  65. static const uint8_t JC5 = 21;
  66. static const uint8_t JC6 = 22;
  67. static const uint8_t JC7 = 23;
  68.                      
  69. static const uint8_t JD0 = 8;
  70. static const uint8_t JD1 = 9;
  71. static const uint8_t JD2 = 10;
  72. static const uint8_t JD3 = 11;
  73. static const uint8_t JD4 = 12;
  74. static const uint8_t JD5 = 13;
  75. static const uint8_t JD6 = 14;
  76. static const uint8_t JD7 = 15;

  77. //#define digitalPinToPCICR(p)    (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (&PCICR) : ((uint8_t *)0))
  78. //#define digitalPinToPCICRbit(p) (((p) <= 7) ? 1 : (((p) <= 15) ? 3 : (((p) <= 23) ? 2 : 0)))
  79. //#define digitalPinToPCMSK(p)    (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))
  80. //#define digitalPinToPCMSKbit(p) ((p) % 8)
  81. #define digitalPinToInterrupt(p)         ((p) == 10 ? 0 : ((p) == 11 ? 1 : ((p) == 2 ? 2 : NOT_AN_INTERRUPT)))

  82. #ifdef ARDUINO_MAIN

  83. const uint16_t PROGMEM port_to_mode_PGM[] =
  84. {
  85.   NOT_A_PORT,
  86.   (uint16_t) &DDRA,
  87.   (uint16_t) &DDRB,
  88.   (uint16_t) &DDRC,
  89.   (uint16_t) &DDRD,
  90. };

  91. const uint16_t PROGMEM port_to_output_PGM[] =
  92. {
  93.   NOT_A_PORT,
  94.   (uint16_t) &PORTA,
  95.   (uint16_t) &PORTB,
  96.   (uint16_t) &PORTC,
  97.   (uint16_t) &PORTD,
  98. };

  99. const uint16_t PROGMEM port_to_input_PGM[] =
  100. {
  101.   NOT_A_PORT,
  102.   (uint16_t) &PINA,
  103.   (uint16_t) &PINB,
  104.   (uint16_t) &PINC,
  105.   (uint16_t) &PIND,
  106. };

  107. const uint8_t PROGMEM digital_pin_to_port_PGM[32] = {
  108.         PB,  // PB0 ** D0
  109.         PB,  // PB1 ** D1
  110.         PB,  // PB2 ** D2
  111.         PB,  // PB3 ** D3
  112.         PB,  // PB4 ** D4
  113.         PB,  // PB5 ** D5
  114.         PB,  // PB6 ** D6
  115.         PB,  // PB7 ** D7
  116.         PD,  // PD0 ** D8
  117.         PD,  // PD1 ** D9
  118.         PD,  // PD2 ** D10
  119.         PD,  // PD3 ** D11
  120.         PD,  // PD4 ** D12
  121.         PD,  // PD5 ** D13
  122.         PD,  // PD6 ** D14
  123.         PD,  // PD7 ** D15
  124.         PC,  // PC0 ** D16
  125.         PC,  // PC1 ** D17
  126.         PC,  // PC2 ** D18
  127.         PC,  // PC3 ** D19
  128.         PC,  // PC4 ** D20
  129.         PC,  // PC5 ** D21
  130.         PC,  // PC6 ** D22
  131.         PC,  // PC7 ** D23
  132.         PA,  // PA7 ** A7 D24
  133.         PA,  // PA6 ** A6 D25
  134.         PA,  // PA5 ** A5 D26
  135.         PA,  // PA4 ** A4 D27
  136.         PA,  // PA3 ** A3 D28
  137.         PA,  // PA2 ** A2 D29
  138.         PA,  // PA1 ** A1 D30
  139.         PA,  // PA0 ** A0 D31
  140. };

  141. const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[32] = {       
  142.         _BV(0),  // PB0 ** D0
  143.         _BV(1),  // PB1 ** D1
  144.         _BV(2),  // PB2 ** D2
  145.         _BV(3),  // PB3 ** D3
  146.         _BV(4),  // PB4 ** D4
  147.         _BV(5),  // PB5 ** D5
  148.         _BV(6),  // PB6 ** D6
  149.         _BV(7),  // PB7 ** D7
  150.         _BV(0),  // PD0 ** D8
  151.         _BV(1),  // PD1 ** D9
  152.         _BV(2),  // PD2 ** D10
  153.         _BV(3),  // PD3 ** D11
  154.         _BV(4),  // PD4 ** D12
  155.         _BV(5),  // PD5 ** D13
  156.         _BV(6),  // PD6 ** D14
  157.         _BV(7),  // PD7 ** D15
  158.         _BV(0),  // PC0 ** D16
  159.         _BV(1),  // PC1 ** D17
  160.         _BV(2),  // PC2 ** D18
  161.         _BV(3),  // PC3 ** D19
  162.         _BV(4),  // PC4 ** D20
  163.         _BV(5),  // PC5 ** D21
  164.         _BV(6),  // PC6 ** D22
  165.         _BV(7),  // PC7 ** D23
  166.         _BV(7),  // PA7 ** A7 D24
  167.         _BV(6),  // PA6 ** A6 D25
  168.         _BV(5),  // PA5 ** A5 D26
  169.         _BV(4),  // PA4 ** A4 D27
  170.         _BV(3),  // PA3 ** A3 D28
  171.         _BV(2),  // PA2 ** A2 D29
  172.         _BV(1),  // PA1 ** A1 D30
  173.         _BV(0),  // PA0 ** A0 D31
  174. };

  175. const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
  176. {
  177.   NOT_ON_TIMER, /* 0  - PB0 */
  178.   NOT_ON_TIMER, /* 1  - PB1 */
  179.   NOT_ON_TIMER, /* 2  - PB2 */
  180.   TIMER0A,             /* 3  - PB3 */
  181. //  TIMER0,             /* 3  - PB3 */
  182.   NOT_ON_TIMER,        /* 4  - PB4 */
  183.   NOT_ON_TIMER, /* 5  - PB5 */
  184.   NOT_ON_TIMER,        /* 6  - PB6 */
  185.   NOT_ON_TIMER,        /* 7  - PB7 */
  186.   NOT_ON_TIMER, /* 8  - PD0 */
  187.   NOT_ON_TIMER, /* 9  - PD1 */
  188.   NOT_ON_TIMER, /* 10 - PD2 */
  189.   NOT_ON_TIMER, /* 11 - PD3 */
  190.   TIMER1B,             /* 12 - PD4 */
  191.   TIMER1A,             /* 13 - PD5 */
  192.   NOT_ON_TIMER, /* 14 - PD6 */
  193.   TIMER2,       /* 15 - PD7 */
  194.   NOT_ON_TIMER, /* 16 - PC0 */
  195.   NOT_ON_TIMER, /* 17 - PC1 */
  196.   NOT_ON_TIMER, /* 18 - PC2 */
  197.   NOT_ON_TIMER, /* 19 - PC3 */
  198.   NOT_ON_TIMER, /* 20 - PC4 */
  199.   NOT_ON_TIMER, /* 21 - PC5 */
  200.   NOT_ON_TIMER, /* 22 - PC6 */
  201.   NOT_ON_TIMER, /* 23 - PC7 */
  202.   NOT_ON_TIMER, /* 24 - PA7 */
  203.   NOT_ON_TIMER, /* 25 - PA6 */
  204.   NOT_ON_TIMER, /* 26 - PA5 */
  205.   NOT_ON_TIMER, /* 27 - PA4 */
  206.   NOT_ON_TIMER, /* 28 - PA3 */
  207.   NOT_ON_TIMER, /* 29 - PA2 */
  208.   NOT_ON_TIMER, /* 30 - PA1 */
  209.   NOT_ON_TIMER  /* 31 - PA0 */
  210. };

  211. #endif
  212. // These serial port names are intended to allow libraries and architecture-neutral
  213. // sketches to automatically default to the correct port name for a particular type
  214. // of use.  For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
  215. // the first hardware serial port whose RX/TX pins are not dedicated to another use.
  216. //
  217. // SERIAL_PORT_MONITOR        Port which normally prints to the Arduino Serial Monitor
  218. //
  219. // SERIAL_PORT_USBVIRTUAL     Port which is USB virtual serial
  220. //
  221. // SERIAL_PORT_LINUXBRIDGE    Port which connects to a Linux system via Bridge library
  222. //
  223. // SERIAL_PORT_HARDWARE       Hardware serial port, physical RX & TX pins.
  224. //
  225. // SERIAL_PORT_HARDWARE_OPEN  Hardware serial ports which are open for use.  Their RX & TX
  226. //                            pins are NOT connected to anything by default.
  227. #define SERIAL_PORT_MONITOR   Serial
  228. #define SERIAL_PORT_HARDWARE  Serial

  229. #endif
复制代码
回复 支持 反对

使用道具 举报

发表于 2015-9-14 20:58:46 | 显示全部楼层
谢谢了,有时间试试!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-17 06:33 , Processed in 0.036583 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表