Arduino的11.0592MHz的处。修改定时器0,delayMicroseconds() [英] Arduino at 11.0592MHz. Modify Timer0, delayMicroseconds()
问题描述
我使用ATMEGA328P在为11.0592MHz与Arduino的环境。我认为该delayMicroseconds()函数是约27%的太快。其原因是,在wiring.c的code假定撒尿时钟现在为8MHz。
现在我尝试修复它。我发现不同的职位,但我不知道什么是最Arduino的兼容的方式。有什么可以推荐的吗?
- 乘以wiring.c变量我们1.27如果F_CPU是11.0592MHz的?很容易,但只影响delayMicroseconds而不是米利斯(),百万分之一(),延时()等。
- 也许从64更改preSCALE因素???
其他的想法或导游?
感谢您提前。
菲利克斯
Arduino的方法是让您的主板的自定义平台,新F_CPU速度。核心库应通过携带这种F_CPU。
这是很容易的,通过做一个boards.txt文件,你的不同。该文件(两者相同)的位置是在两个电流IDE的不同。在的情况下的Arduino IDE 1.0.5:
C:\\用户\\ mflaga \\文档\\的Arduino \\五金\\ myArduino11MgHz \\ boards.txt
块引用>和在1.5.5的情况:
C:\\用户\\ mflaga \\文档\\的Arduino \\五金\\ myArduino11MgHz \\ AVR \\ boards.txt
块引用>如果你的情况草图目录将是不同的。
#请参阅:HTTP://$c$c.google.com/p/arduino/wiki/Platforms################################################## ############myArduino11MgHz.name = Arduino的11MgHzmyArduino11MgHz.vid.0 = 0x2341
myArduino11MgHz.pid.0 = 0x0043
myArduino11MgHz.vid.1 = 0x2341
myArduino11MgHz.pid.1 = 0×0001myArduino11MgHz.upload.tool = AVRDUDE
myArduino11MgHz.upload.protocol =的Arduino
myArduino11MgHz.upload.maximum_size = 32256
myArduino11MgHz.upload.maximum_data_size = 2048
myArduino11MgHz.upload.speed = 115200myArduino11MgHz.bootloader.tool = AVRDUDE
myArduino11MgHz.bootloader.low_fuses = 0xFF的
myArduino11MgHz.bootloader.high_fuses =写0xDE
myArduino11MgHz.bootloader.extended_fuses = 0×05
myArduino11MgHz.bootloader.unlock_bits = 0x3F的
myArduino11MgHz.bootloader.lock_bits =为0x0F
myArduino11MgHz.bootloader.file = optiboot / optiboot_atmega328.hexmyArduino11MgHz.build.mcu = ATMEGA328P
myArduino11MgHz.build.f_cpu = 11059200L
myArduino11MgHz.build.board = AVR_myArduino11MgHz
myArduino11MgHz.build.core =的Arduino:Arduino的
myArduino11MgHz.build.variant = Arduino的:标准################################################## ############下面是href=\"http://sourceforge.net/projects/arduinobdeditor/\" rel=\"nofollow\">第三方GUI编辑的board.txt的
免责声明。以上并编译和正常工作的。在那里我有没有实际测试过,并加载到一个单位。
这是说,我希望bootloader的F_CPU不匹配。有三种可能的解决方案,以本
第一;在optiboot加载器应该有一个相应的目标有以下偏差:
\\ Arduino的1.5.5 \\五金\\ Arduino的\\ AVR \\引导程序\\ optiboot \\ Makefile文件
块引用>myArduino11MgHz:AVR_FREQ = 11059200L
二;更改boards.txt上传速度以匹配= 115200变化*(一千六万分之一千一百○五万九千二)。
myArduino11MgHz.upload.speed = 79626
这是一个非一般的波特率,无论是AVRDUDE或串行端口可支持它。
第三;不要使用启动加载,通过经由ISP编程上传
我也同样计划做出板具有不同F_CPU,但实际上只作出定制板,具有相同的速度。我会很好奇,想知道如果以上实际工作,你的情况。
I am using the ATMega328P at 11.0592MHz with the Arduino environment. I recognized that the delayMicroseconds() function is about 27% too fast. The reason is, that the code in wiring.c assumes that the clock peed is now 8MHz.
Now I try to fix it. I found different posts but I am not sure what is the most Arduino compatible way. What can you recommend?
- Multiply the variable "us" in wiring.c with 1.27 if the F_CPU is 11.0592MHz? Easy but only affects delayMicroseconds and not millis(), micros(), delay(), etc.
- Change the prescale factor maybe from 64 to ???
Other ideas or guides?
Thank you in advance.
Felix
解决方案The Arduino way would be to make a custom PLATFORM for your board with that of the new F_CPU speed. The core libraries should carry this F_CPU through.
This is easy enough, by making a boards.txt file with your differences. Where the location of the file (same between the two) is different between the two current IDE's. In the case of Arduino IDE 1.0.5:
C:\Users\mflaga\Documents\Arduino\hardware\myArduino11MgHz\boards.txt
and in the case of 1.5.5:
C:\Users\mflaga\Documents\Arduino\hardware\myArduino11MgHz\avr\boards.txt
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:
\arduino-1.5.5\hardware\arduino\avr\bootloaders\optiboot\Makefile
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()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!