历史上的今天
返回首页

历史上的今天

今天是:2025年03月30日(星期日)

正在发生

2020年03月30日 | 把ATmega128开发板转为Arduino

2020-03-30 来源:eefocus

AVR环境:


编译环境: ubuntu + avr-gcc 


烧写工具: avrdude+usbasp


具体构建步骤查看上一篇博客。


avr环境多种多样,在linux下还可以用eclipse集成环境。在window下推荐用WINAVR,其实本质上和linux下一样是用avr-gcc,烧写工具用prgisp.当然有了avr jtag仿真器就更好了,不用usbasp.


下载arduino工具:


arduino.cc/en/Main/Software


我下载的linux 64位版本,下载后解压到主目录下。


开发板:


BK-AVR128开发板   


一、制作属于atmega128的bootloader


代码主要是arduino工具自带的,编译时有点问题,我改了几处。


可以直接到我的资源里面下载编译好的hex文件直接烧写到单片机就可以了:


download.csdn.net/detail/canyue102/5809329


源代码boot _mega128.c:


/**********************************************************/

/* Serial Bootloader for Atmel megaAVR Controllers        */

/*                                                        */

/* tested with ATmega8, ATmega128 and ATmega168           */

/* should work with other mega's, see code for details    */

/*                                                        */

/*                                           */

/*                                                        */

/*                                                        */

/* 20090308: integrated Mega changes into main bootloader */

/*           source by D. Mellis                          */

/* 20080930: hacked for Arduino Mega (with the 1280       */

/*           processor, backwards compatible)             */

/*           by D. Cuartielles                            */

/* 20070626: hacked for Arduino Diecimila (which auto-    */

/*           resets when a USB connection is made to it)  */

/*           by D. Mellis                                 */

/* 20060802: hacked for Arduino by D. Cuartielles         */

/*           based on a previous hack by D. Mellis        */

/*           and D. Cuartielles                           */

/*                                                        */

/* Monitor and debug functions were added to the original */

/* code by Dr. Erik Lins, chip45.com. (See below)         */

/*                                                        */

/* Thanks to Karl Pitrich for fixing a bootloader pin     */

/* problem and more informative LED blinking!             */

/*                                                        */

/* For the latest version see:                            */

/* http://www.chip45.com/                                 */

/*                                                        */

/* ------------------------------------------------------ */

/*                                                        */

/* based on stk500boot.c                                  */

/* Copyright (c) 2003, Jason P. Kyle                      */

/* All rights reserved.                                   */

/* see avr1.org for original file and information         */

/*                                                        */

/* This program is free software; you can redistribute it */

/* and/or modify it under the terms of the GNU General    */

/* Public License as published by the Free Software       */

/* Foundation; either version 2 of the License, or        */

/* (at your option) any later version.                    */

/*                                                        */

/* This program is distributed in the hope that it will   */

/* be useful, but WITHOUT ANY WARRANTY; without even the  */

/* implied warranty of MERCHANTABILITY or FITNESS FOR A   */

/* PARTICULAR PURPOSE.  See the GNU General Public        */

/* License for more details.                              */

/*                                                        */

/* You should have received a copy of the GNU General     */

/* Public License along with this program; if not, write  */

/* to the Free Software Foundation, Inc.,                 */

/* 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */

/*                                                        */

/* Licence can be viewed at                               */

/* http://www.fsf.org/licenses/gpl.txt                    */

/*                                                        */

/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */

/* m8515,m8535. ATmega161 has a very small boot block so  */

/* isn't supported.                                       */

/*                                                        */

/* Tested with m168                                       */

/**********************************************************/

 

/* $Id$ */

 

 

/* some includes */

#include

#include

#include

#include

#include

#include

 

/* the current avr-libc eeprom functions do not support the ATmega168 */

/* own eeprom write/read functions are used instead */

#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__)

#include

#endif

 

/* Use the F_CPU defined in Makefile */

 

/* 20060803: hacked by DojoCorp */

/* 20070626: hacked by David A. Mellis to decrease waiting time for auto-reset */

/* set the waiting time for the bootloader */

/* get this from the Makefile instead */

#define MAX_TIME_COUNT (F_CPU>>1)

 

/* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */

#define MAX_ERROR_COUNT 5

 

/* set the UART baud rate */

/* 20060803: hacked by DojoCorp */

//#define BAUD_RATE   115200

#ifndef BAUD_RATE

#define BAUD_RATE   19200

#endif

 

 

/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */

/* never allow AVR Studio to do an update !!!! */

#define HW_VER 0x02

#define SW_MAJOR 0x01

#define SW_MINOR 0x10

 

 

/* Adjust to suit whatever pin your hardware uses to enter the bootloader */

/* ATmega128 has two UARTS so two pins are used to enter bootloader and select UART */

/* ATmega1280 has four UARTS, but for Arduino Mega, we will only use RXD0 to get code */

/* BL0... means UART0, BL1... means UART1 */

#ifdef __AVR_ATmega128__

#define BL_DDR  DDRF

#define BL_PORT PORTF

#define BL_PIN  PINF

#define BL0     PINF7

#define BL1     PINF6

#elif defined __AVR_ATmega1280__

/* we just don't do anything for the MEGA and enter bootloader on reset anyway*/

推荐阅读

史海拾趣

BUSSMANN公司的发展小趣事

随着汽车工业的快速发展,对熔断器的需求也急剧增加。Bussmann五兄弟敏锐地抓住了这一市场机遇,开始专注于汽车熔断器的研发和生产。他们深入研究汽车电路的特点,不断优化熔断器的设计和性能,使其能够更好地适应汽车的工作环境。凭借这一创新,Bussmann的汽车熔断器迅速占领了市场,为公司的发展奠定了坚实的基础。

Aplus Integrated Circuits公司的发展小趣事

随着公司产品的不断优化和升级,Aplus Integrated Circuits开始寻求与国际市场的接轨。公司积极参与国际电子行业的交流与合作,与多家国际知名企业建立了稳定的合作关系。通过引进国外先进的技术和管理经验,公司的产品逐渐走向国际化,市场竞争力得到了进一步提升。

CIRCUITCO公司的发展小趣事

CIRCUITCO公司自创立之初,就致力于电子电路技术的研发。在某一时期,公司投入大量资源研发新型高性能电路板。经过数年的努力,团队终于成功开发出一款具有更高集成度、更低能耗的电路板。这一突破不仅提升了公司的技术实力,也使其在市场上获得了显著的竞争优势。随着这款新产品的推出,CIRCUITCO公司的业绩迅速攀升,成为行业内的佼佼者。

台湾固锝(GD)公司的发展小趣事
使用测试仪器对放大器的增益、噪声、带宽等性能参数进行测量和评估。
G24 Innovations公司的发展小趣事

随着产品质量的不断提升,远阳开始将目光投向更广阔的市场。公司制定了详细的市场拓展计划,并加大了品牌营销力度。2010年前后,远阳成功进军国际市场,与多家国际知名企业建立了长期合作关系。同时,公司也注重在国内市场的布局,通过参加各类行业展会、举办技术研讨会等方式,不断提升品牌知名度和影响力。这一时期,远阳的产品线不断丰富,涵盖了HDMI、光纤线、DP线等多个系列,成为了数据工程电缆领域的佼佼者。

Aydin Corp公司的发展小趣事

品质是Aydin Corp的生命线。公司始终坚持品质至上的原则,从原材料采购到生产流程控制,再到产品出厂检验,每一个环节都严格把控品质。同时,公司还注重品牌建设,通过提升产品形象和服务质量,逐渐树立了良好的品牌形象。这些努力使得Aydin Corp的产品在市场上获得了广泛的认可和好评。

问答坊 | AI 解惑

基于语音芯片ISd4003的程序设计!

c语言编写!编译连接成功!…

查看全部问答>

《谁说手机天线没有技术含量?》理论?实践?

有位研究生网友提出,就是没觉得手机天线行业有什么技术含量,理由是这个行业用不到公式。 在此,我想有必要就此进行一些陈述,这也是长久以来自己的一些想法。 百闻不如一见,在学校里做东西,和在公司里做东西,是有差异的,这个差异有的时候还 ...…

查看全部问答>

动手拆卸电子设备,如何预防被电?

有时因为没有电路图,但是自己所从事的行业好歹与电子沾边,于是总喜欢拆开来看看或者动手调调。 有的时候,不小心就被某个地方电一下。 哎,现在有点怕了。 请大家说说你们是否被电过?如何预防?…

查看全部问答>

电子工程师:改变了人们的生活体验,却降低了自己的社会地位

娱乐界的颁奖晚会、红地毯炒的沸沸扬扬,吸引N多媒体的目光,而为什么没有专门为科学家和工程师举办多一些这种活动? 美国《纽约时报》专栏作家Thomas L. Friedman提出建议,认为应该大力宣传像是“英特尔科学奖”颁奖晚会这样的活动,让其现场实 ...…

查看全部问答>

matlab .dat转换成.mat

function gps; sDataPath = \'D:\\s\\\'; sDataFile = dir(sDataPath); %sDataPath这是你存放dat数据文件的路径 m = length(sDataFile); k = 0; for i = 1:m     if sDataFile(i).isdir         co ...…

查看全部问答>

我要找硬件开发兼职人员(在杭州)急

我要找硬件开发兼职人员(在杭州)急 联系qq 33938019 msn:zhubin@zhubin.net 邮箱:zhubin@zhubin.net …

查看全部问答>

好多小工具及资料

这几天逛了论坛100多页找来的,整理了一下,需要的就下载咯....…

查看全部问答>

刚学VHDL的新手求教一段程序

有a,b,c,d四个输入数据,首先让A0=0,A1=0时输出y…

查看全部问答>

关于有人用错误文档骗币的举报

看看这个帖子,什么都明白了   https://bbs.eeworld.com.cn/thread-290320-1-1.html   ydw621会员放错误文档,完全是骗论坛币…

查看全部问答>

dsp新手

各位高手好:                   小弟現在系統架構 是外部訊號經由\"訊號截取卡\"傳送至pc給matlab進行運\算處理 然後輸出,     而matlab ...…

查看全部问答>