I would like to see the definition of CLKPR. I guess that similarly to PORTB and other registers, it should be defined by the toolchain? (see Where is PORTB defined? )

  • Am I right?
  • Where should I look for this toolchain on Ubuntu 16.04? I tried locate and find commands in terminal with various strings relating to the toolchain expected path / files, but could not find it (tips and tricks on how I may look for such paths in the future would be welcome ;) ).

1 Answer 1


grep is the command you want:

foo@bar:~/arduino-1.8.2$ grep -r CLKPR .
Binary file ./hardware/tools/avr/avr/lib/avr35/crtattiny167.o matches
Binary file ./hardware/tools/avr/avr/lib/avr35/crtat90usb82.o matches
Binary file ./hardware/tools/avr/avr/lib/avr35/crtatmega8u2.o matches
Binary file ./hardware/tools/avr/avr/lib/avr5/crtat90pwm161.o matches
Binary file ./hardware/tools/avr/avr/lib/avr5/crtatmega649p.o matches
Binary file ./hardware/tools/avr/avr/lib/avr5/crtatmega168pa.o matches
./hardware/tools/avr/avr/include/avr/io90pwm216.h:#define CLKPR   _SFR_MEM8(0x61)
./hardware/tools/avr/avr/include/avr/iom329.h:#define CLKPR   _SFR_MEM8(0x61)
./hardware/tools/avr/avr/include/avr/iom165p.h:#define CLKPR   _SFR_MEM8(0x61)
./hardware/tools/avr/avr/include/avr/iom48p.h:#define CLKPR _SFR_MEM8(0x61)
./hardware/tools/avr/avr/include/avr/iom644pa.h:#define CLKPR _SFR_MEM8(0x61)
./hardware/tools/avr/avr/include/avr/ioa6289.h:#define CLKPR _SFR_IO8(0x3C)
./hardware/arduino/avr/bootloaders/caterina-Arduino_Robot/Caterina.h:       #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
./hardware/arduino/avr/bootloaders/caterina-LilyPadUSB/Caterina.h:      #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
./hardware/arduino/avr/bootloaders/caterina/Caterina.h:     #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))

So it's defined in the IO header for the chip you are using (hardware/tools/avr/avr/include/avr/io[chip].h). So for the '328p that's hardware/tools/avr/avr/include/avr/iom328p.h.

  • This is great, thank you! A couple of noobs questions: -1: this is not the toolchain, isn t it? -2: so for an Arduino Mega 1280, I should look at iom1280.h isn t it? But there is no CLKPR in it (grep CLKPR iom1280.h returns nothing while in the right folder), while I am quite sure it is also called CLKPR for the 1280 (I checked in the datasheet). Where is CLKPR defined for the Mega then?
    – Zorglub29
    Dec 5, 2017 at 17:31
  • Yes, that is the toolchain. It will be in that file, but it may be called something else. Edit the file and browse through it.
    – Majenko
    Dec 5, 2017 at 17:59
  • iom1280.h includes the standard file iomxx0_1.h. That defines CLKPR as _SFR_MEM8(0x61).
    – Majenko
    Dec 5, 2017 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.