用arduino mega2560通过isp给 arduino uno烧录程序

用arduino mega2560通过isp给 arduino uno烧录程序

一直想通过最基本的方式来烧录arduino程序,没有bootloader,不使用arduino IDE,基于avr-libc库来写程序,再用avrdude来烧录。

  • 由于手上有两块arduino板,一块uno,一块mega2560。就想着用mega来做isp工具,来给uno烧录程序,就有了以下过程

  • mega做成isp烧录工具

    1. 在arduino IDE里写入isp程序:

    2. 首先选择工具档: Tools > Board > mega2560

    3. 再选择 File > Example > ArduinoISP

    4. 编译上传


  • 连接meag和uno

    1. 参考这篇文章

      Arduino as ISP and Arduino Bootloaders | Arduino Documentation

    2. 具体是这张图:

    3. 描述如下:

      The Arduino MEGA above is programming an Arduino UNO connecting D51-D11, D50-D12, D52-D13, GND-GND, 5V-5V and D10 to RESET. This type of board needs a 10µF electrolytic capacitor connected to RESET and GND with the positive (long leg) connected to RESET. The capacitor has to be placed after the programmer board has been loaded with the ISP sketch.

      The 10µF electrolytic capacitor connected to RESET and GND of the programming board is needed only for the boards that have an interface between the microcontroller and the computer's USB, like Mega, UNO, Mini, Nano. Boards like Leonardo, Esplora and Micro, with the USB directly managed by the microcontroller, don't need the capacitor.

      注意:reset引脚上要接一 个电容


  • 通过arduino IDE确认烧录命令

    1. 打开一个想烧录的例子程序,比如 Blink
    2. 选择目标板(uno):Tools > Board > Arduino Uno
    3. 选择工具板 (mega2560):Tools > Port > 选择mega2560 (来作为"Arduino as ISP")
    4. 选择 Tools > Programmer > Arduino as ISP
    5. 注意,选择 Sketch > Upload Using Programmer ;而不是点工具栏的 编译。
    6. 第5步之后,就会通过isp方式,擦除uno的flash,并烧录blink的程序。可以在arduino IDE后台的log里找到刚刚执行的烧录的命令:
      • 我的系统是arch linux,我的用户目录为 /home/suah,截取的log的第一行就是烧录的命令,后续我们自己修改目标文件,就可以随时烧录自己的程序了

        /home/suah/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/home/suah/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyACM0 -b19200 -Uflash:w:/tmp/arduino_build_456577/Blink.ino.hex:i
        
        avrdude: Version 6.3-20190619
                 Copyright (c) 2000-2005 Brian Dean, <http://www.bdmicro.com/>
                 Copyright (c) 2007-2014 Joerg Wunsch
        
            
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值