本文介绍了Arduino的11.0592MHz的处。修改定时器0,delayMicroseconds()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ATMEGA328P在为11.0592MHz与Arduino的环境。我认为该delayMicroseconds()函数是约27%的太快。其原因是,在wiring.c的code假定撒尿时钟现在为8MHz。

现在我尝试修复它。我发现不同的职位,但我不知道什么是最Arduino的兼容的方式。有什么可以推荐的吗?


  1. 乘以wiring.c变量我们1.27如果F_CPU是11.0592MHz的?很容易,但只影响delayMicroseconds而不是米利斯(),百万分之一(),延时()等。

  2. 也许从64更改preSCALE因素???

其他的想法或导游?

感谢您提前。

菲利克斯


解决方案

Arduino的方法是让您的主板的自定义平台,新F_CPU速度。核心库应通过携带这种F_CPU。

这是很容易的,通过做一个boards.txt文件,你的不同。该文件(两者相同)的位置是在两个电流IDE的不同。在的情况下的Arduino IDE 1.0.5:

and in the case of 1.5.5:

Where in your case the sketch directory would be different.

# See: http://code.google.com/p/arduino/wiki/Platforms

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

myArduino11MgHz.name=Arduino 11MgHz

myArduino11MgHz.vid.0=0x2341
myArduino11MgHz.pid.0=0x0043
myArduino11MgHz.vid.1=0x2341
myArduino11MgHz.pid.1=0x0001

myArduino11MgHz.upload.tool=avrdude
myArduino11MgHz.upload.protocol=arduino
myArduino11MgHz.upload.maximum_size=32256
myArduino11MgHz.upload.maximum_data_size=2048
myArduino11MgHz.upload.speed=115200

myArduino11MgHz.bootloader.tool=avrdude
myArduino11MgHz.bootloader.low_fuses=0xFF
myArduino11MgHz.bootloader.high_fuses=0xDE
myArduino11MgHz.bootloader.extended_fuses=0x05
myArduino11MgHz.bootloader.unlock_bits=0x3F
myArduino11MgHz.bootloader.lock_bits=0x0F
myArduino11MgHz.bootloader.file=optiboot/optiboot_atmega328.hex

myArduino11MgHz.build.mcu=atmega328p
myArduino11MgHz.build.f_cpu=11059200L
myArduino11MgHz.build.board=AVR_myArduino11MgHz
myArduino11MgHz.build.core=arduino:arduino
myArduino11MgHz.build.variant=arduino:standard

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

Here is a 3rd party GUI Editor of the board.txt.

Disclaimer. The above does compile and should work fine. Where I have not actually tested and loaded into a unit.


That said, I would expect the bootloader's F_CPU not to match. There are three possible solutions to this.

First; the optiboot loader should have a corresponding target with the below deviation:

myArduino11MgHz: AVR_FREQ = 11059200L

Second; Change the boards.txt upload speed to match the change of =115200*(11059200/16000000).

myArduino11MgHz.upload.speed=79626

This being a non typical baud rate, either avrdude or the serial port may support it.

Third; Don't use the bootload, by uploading via the ISP programmer.


I have likewise planned to make a board with a different F_CPU, but only actually made custom boards, with the same speed. I would be curious to know if the above actually works, in your case.

这篇关于Arduino的11.0592MHz的处。修改定时器0,delayMicroseconds()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 06:52