Atmega328P: problems with switching to 8 MHz.

I have a device built on the Atmega328P (16 MHz, 5V) controller
I use the Arduino IDE platform and as a programmer for Atmega328P I use the Arduino UNO board. I can easily write new sketches to the controller.
In order to save energy, I want to switch to a frequency of 8 MHz. My settings: TOOLS -> Arduino Pro or Pro Mini, Atmega328P (8 MHz, 3.3V).
The sketch does not load with a 16 MHz oscillator, and also with a 8 MHz oscillatorr.

avrdude: stk500_getsync () attempt 1 of 10: not in sync: resp = 0x00
avrdude: stk500_getsync () attempt 2 of 10: not in sync: resp = 0xe0
avrdude: stk500_getsync () attempt 3 of 10: not in sync: resp = 0xe0
avrdude: stk500_getsync () attempt 4 of 10: not in sync: resp = 0xe0
avrdude: stk500_getsync () attempt 5 of 10: not in sync: resp = 0xe0
avrdude: stk500_getsync () attempt 6 of 10: not in sync: resp = 0x00
avrdude: stk500_getsync () attempt 7 of 10: not in sync: resp = 0xe0
avrdude: stk500_getsync () attempt 8 of 10: not in sync: resp = 0x00
avrdude: stk500_getsync () attempt 9 of 10: not in sync: resp = 0x00
avrdude: stk500_getsync () attempt 10 of 10: not in sync: resp = 0xe0
An error occurred while loading the sketch.

Help me download the sketch. Thank you in advance.

Sorry for the poor computer translation.

It's not a trivial matter of changing the board in the IDE.
The ProMini itself has to be configured, physically, as a 3V device.

You have to understand how the loading process works.

[ Each chip type has a set of hardware signature bytes that avrdude will check before uploading a bootloader.
This means the board setting for this process may sometimes be different from during sketch uploading ]

But the bootloader itself has a set of programmed signature bytes that it reports to the sketch uploader. These are compiled into the bootloader.

The selected board type determines the signature bytes the uploader expects to find, which must match those of the bootloader. The clock rate also has to match, and the upload method has to match too, I think.

Thus the bootloader in the chip determines which board types will work. If you want 8MHz operation during upload you need the bootloader compiled for 8MHz installed in the chip I believe.

You ought to be able to upload at 16MHz with the standard bootloader using Pro Mini 16MHz settings I think,
but the speed of millis() etc will not be what you expect if you subsequently clock at 8MHz.

MarkT:
You have to understand how the loading process works.

[ Each chip type has a set of hardware signature bytes that avrdude will check before uploading a bootloader.
This means the board setting for this process may sometimes be different from during sketch uploading ]

But the bootloader itself has a set of programmed signature bytes that it reports to the sketch uploader. These are compiled into the bootloader.

The selected board type determines the signature bytes the uploader expects to find, which must match those of the bootloader. The clock rate also has to match, and the upload method has to match too, I think.

Thus the bootloader in the chip determines which board types will work. If you want 8MHz operation during upload you need the bootloader compiled for 8MHz installed in the chip I believe.

You ought to be able to upload at 16MHz with the standard bootloader using Pro Mini 16MHz settings I think,
but the speed of millis() etc will not be what you expect if you subsequently clock at 8MHz.

I can not agree with you. If we load the Arduino Pro Mini module through a serial USB converter, then the delay () operators, millis () and others are read correctly. The speed in the serial monitor also does not change: if 9600 is specified in the sketch, then information at a speed of 9600 is displayed in the monitor.
All parameters are set during sketch recording.

Arduino Pro or Pro Mini (3.3V, 8 MHz) w / ATmega328

------------------------------------------------ -

pro.menu.cpu.8MHzatmega328 = ATmega328 (3.3V, 8 MHz)

pro.menu.cpu.8MHzatmega328.upload.maximum_size = 30720
pro.menu.cpu.8MHzatmega328.upload.maximum_data_size = 2048
pro.menu.cpu.8MHzatmega328.upload.speed = 57600

pro.menu.cpu.8MHzatmega328.bootloader.low_fuses = 0xFF
pro.menu.cpu.8MHzatmega328.bootloader.high_fuses = 0xDA
pro.menu.cpu.8MHzatmega328.bootloader.extended_fuses = 0xFD
pro.menu.cpu.8MHzatmega328.bootloader.file = atmega / ATmegaBOOT_168_atmega328_pro_8MHz.hex

pro.menu.cpu.8MHzatmega328.build.mcu = atmega328p
pro.menu.cpu.8MHzatmega328.build.f_cpu = 8000000L

This is a snippet from board.txt. I hope you understand me.

runaway_pancake:
It's not a trivial matter of changing the board in the IDE.

Yes, a non-trivial question. I am convinced that there are readers on the forum who know the answer to the question and will help me.

Cadis:
I have a device built on the Atmega328P (16 MHz, 5V) controller

You might want to reveal exactely which device that is, if you want qualified help instead of wild guesses.

Have a look at Nick Gammon's program to detect chip types. He also has a program for uploading a bootloader - which is what sets the fuse bits for the different clock speeds

...R

Cadis:
All parameters are set during sketch recording.

That's incorrect. The configuration fuses:

Cadis:
pro.menu.cpu.8MHzatmega328.bootloader.low_fuses = 0xFF
pro.menu.cpu.8MHzatmega328.bootloader.high_fuses = 0xDA
pro.menu.cpu.8MHzatmega328.bootloader.extended_fuses = 0xFD

are only set when you do a Tools > Burn Bootloader, which requires you to have an ISP programmer connected between your device and your computer. If you don't own an ISP programmer you can use a spare Arduino board as an "Arduino as ISP" programmer:
https://www.arduino.cc/en/Tutorial/ArduinoISP

Note that the configuration fuses of the "Arduino Pro or Pro Mini (3.3V, 8 MHz) w / ATmega328" board definition are for an external 8 MHz clock source. If you instead want to use the 8 MHz RC oscillator on the ATmega328P, then I would recommend using MiniCore with the "Tools > Clock > 8 MHz internal" setting selected.

I've deleted your other cross post @Cadis.

Cross posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes writing a detailed answer on this thread, without knowing that someone else already did the same in the other thread.

Repeated cross posting will result in a suspension from the forum.

In the future, please take some time to pick the forum section that best suits the topic of your question and then only post once to that forum section. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum section. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.