Sorry for my poor English. I'm from Brazil and I'm using automatic translation.
I'm having trouble changing the internal oscillator of an Atmega328PB from 1MHz to 8MHz.
Before this post, I saw several posts with similar issues, but with different configurations than mine, so I'll explain what's happening to me.
I have a custom board consisting of an Atmega328PB (no external crystal), an ISP connector, and a buzzer, as shown in the schematic below.
I'm using the Arduino IDE 2.3.6 and an Arduino Nano to program the Atmega328PB. To add support for the Atmega328PB, I included the following URL in the board manager:
https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
Then I configured the following in the Tools menu of the Arduino IDE:
Board: “ATmega 328”
Bootloader: “No bootloader”
Clock: “Internal 8MHz”
Variant: “328PB”
Programmer: “Arduino as ISP”
Then I wrote the following code:
#define BUZZER PIN_PD6
void setup() {
// put your setup code here, to run once:
pinMode(BUZZER, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite (BUZZER, HIGH);
delay(5);
digitalWrite(BUZZER, LOW);
delay(1000);
}
When I upload the sketch to the Atmega328PB via Arduino Nano, the buzzer starts to cycle on and off, as expected, but at a frequency 8 times lower, which suggests that the Atmega328PB clock is still operating at 1MHz. In fact, when I change the clock option (Tools > Clock) to "Internal 1MHz," the buzzer frequency is correct.
What can I do to change the internal oscillator frequency to 8MHz?

