ATMEGA328P使用内部8MRC振荡器(2015-07-05 19:50:49)

计划做个蓝牙的接收机,用来控制四轴的飞控板。

使用的是ATMEAGE328P,不想再自己实现PWM了,它自带了6通道的PWM。为了能轻一点,没有设计外置晶振,打算用内部的。

板已经打好了,回来一对蓝牙控制板就吐血了,脚画错了。

ATMEGA328P使用内部8MRC振荡器(2015-07-05 19:50:49)_第1张图片
接收板

ATMEGA328P使用内部8MRC振荡器(2015-07-05 19:50:49)_第2张图片
接收板

没办法,只能先试试程序了。为了能让Ardunio开发环境支持,参照这个网页,在Ardunio 1.0.4下测试成功

http://forum.arduino.cc/index.php?topic=124879.0

首先用文本编辑器打开arduino-1.0.4\hardware\arduino\bootloaders\optiboot下的Makefile文件,在标准的atmega328p这段后面,加入下面这段配置:

# Standard atmega328, only at 38,400 baud for closer clock accuracy AND using 8Mhz internal RC oscillator

#

atmega328_384_8: TARGET = atmega328

atmega328_384_8: MCU_TARGET = atmega328p

atmega328_384_8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=38400'

atmega328_384_8: AVR_FREQ = 8000000L

atmega328_384_8: LDSECTIONS= -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe

atmega328_384_8: $(PROGRAM)_atmega328_384_8.hex

atmega328_384_8: $(PROGRAM)_atmega328_384_8.lst

atmega328_384_8_isp: atmega328

atmega328_384_8_isp: TARGET = atmega328

atmega328_384_8_isp: MCU_TARGET = atmega328p

# 512 byte boot, SPIEN

atmega328_384_8_isp: HFUSE = DE

# Int. RC Osc. 8MHz, slowly rising power-65ms

atmega328_384_8_isp: LFUSE = E2

# 2.7V brownout

atmega328_384_8_isp: EFUSE = 05

atmega328_384_8_isp: isp

然后打开windows的控制台程序,进入hardware\arduino\bootloaders\optiboot文件下

在控制台中输入并回车

omakeatmega328_384_8

这个atmega328_384_8参数指的就是上面定义的支持内部8M RC的HEX文件。

编译完成后,atmega328_384_8.hex就生成好了。

现在用文本编辑器打开arduino-1.0.4\hardware\arduino下的board.txt文件,并添加下面这段文字

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

atmega328_384_8.name=ATmega328 Optiboot @ 38,400baud w/ 8MHz Int. RC Osc.

atmega328_384_8.upload.protocol=arduino

atmega328_384_8.upload.maximum_size=30720

atmega328_384_8.upload.speed=38400

atmega328_384_8.bootloader.low_fuses=0xE2

atmega328_384_8.bootloader.high_fuses=0xDE

atmega328_384_8.bootloader.extended_fuses=0x05

atmega328_384_8.bootloader.path=optiboot

atmega328_384_8.bootloader.file=optiboot_atmega328_384_8.hex

atmega328_384_8.bootloader.unlock_bits=0x3F

atmega328_384_8.bootloader.lock_bits=0x0F

atmega328_384_8.build.mcu=atmega328p

atmega328_384_8.build.f_cpu=8000000L

atmega328_384_8.build.core=arduino

atmega328_384_8.build.variant=standard

这样就定好了一个新的板子了。关掉ardunio IDE,再打开,板子列表里面就多了ATmega328 Optiboot @ 38,400baud w/ 8MHz Int. RC Osc.这一项。

选中后测试下烧入bootloader完全没有问题。

至于自己设计的板子,又得重打样了。

你可能感兴趣的:(ATMEGA328P使用内部8MRC振荡器(2015-07-05 19:50:49))