Arduino at 11.0592MHz. Modify Timer0, delayMicroseconds()

前端 未结 1 2002
孤街浪徒
孤街浪徒 2021-01-23 15:16

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 w

相关标签:
1条回答
  • 2021-01-23 15:41

    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.

    0 讨论(0)
提交回复
热议问题