I made a little program that use serial link (9600 Bauds) to send a message and blinks a LED. This one works well on the Arduino board with an ATMega328P, but I want to use that program on an other ATMega328P, with minimal configuration and 8MHz internal clock. So, I burned the bootloader on it using Arduino Board as ISP and after, the program. The LED blinks well, but the serial link send me bad caracters. So I suppose that the bootloader is right installed and program too, but I can't understand why the serial link doesn't work. I also tried with an external 16Mhz clock, but the result is the same. Is someone met that problem and solved it ? Thanks a lot !
Always show us a good schematic of your proposed circuit.
Show us good images of your ‘actual’ wiring.
Give links to components.
In the Arduino IDE, use CtrlT or CMDT to format your code then copy the complete sketch.
Use the < CODE / > icon from the ‘posting menu’ to attach the copied sketch.
No needs to show a schematic. I'm using the usual cabling to flash the bootloader, and after, I put my new ATMega328P on the Arduino board instead of the one that I use to burn the bootloader. In that case, it looks like an simple Arduino board.
Sorry, but we need to see your schematic and good images for your project.
We examine these to confirm the often missed elements that new people overlook.
This picture show the cabling to burn the bootloader. To burn it, I disconnect the resistor and the LED, otherwise I have a signature problem. But after reset and connect them, the LED blinks. When I put it on the Arduino board, that blinks too but the serial link doesn't works.
In the Arduino IDE, use CtrlT or CMDT to format your code then copy the complete sketch.
Use the < CODE / > icon from the ‘posting menu’ to attach the copied sketch.
Since you set the oscillator to 8MHz internal, did you compile the code for an 8MHz processor?
Did you upload the code using the ISP programmer? If so, you erased the bootloader code and will only be able to upload new code using an ISP programmer.
What baud rate are you using for Serial? The internal oscillator is not highly accurate, faster baud rates may not work well.
As a test, try setting the serial monitor baud rate to 1/2 the baud rate used in the code.
A schematic is required. As already pointed out, your breadboard circuit lacks critical components, which is one of several possible reasons why it does not work.
I found 0,1uF capacitor (one ceramic and the other electrolytic) and followed your advice, and this is magical, that's works but that's strange. I did lot of tests, and I also managed to use software serial for DFPlayerMini control, which is my first goal. I did the same thing on two different ATMega328P, their sofware serail are working, but the hardware serial is working just on one of them, like one is maybe deficient...
PS : If you're interested, I followed that tutorial for bootloader burn, but it seems that it is incomplete...
So now, I have others questions :
Is that decoupling capacitors are mandatory even after flashing, for program execution or I can remove them ?
Is is normal that I can't handle to flash a new program if I put my ATMega328P on the Arduino board like I can do it with the one I use to flash by ISP ?
The reset LED should blink at start, but mine are not. The ATMega328P I use to flash by ISP is blinking. Do you know why ?
Decoupling capacitors are mandatory at all times. They reduce the possibility that electrical noise in the power leads corrupts memory and/or interferes with processor activity.
I use the Arduino IDE menus and example sketch "Arduino as ISP" to burn it.
I didn't find specifics parameters to compile for 8Mhz or other speed, are there any ?
If I understand well, the ISP programmer can't provide me the capability to flash my ATMega328P directly with the Arduino board. Is there a way to do it ?
I use 9600 bauds for serial, and yes I read that this is the max for 8Mhz internal clock but this is ok.
Those parameters are in the board definitions, which in turn depend on which Arduino core you are using.
If I understand well, the ISP programmer can't provide me the capability to flash my ATMega328P directly with the Arduino board. Is there a way to do it ?
The question is unclear. Which ISP programmer? Which Arduino board?
To simplify my develpment and debug, I would like to put my ATMega328P on an Arduino Board, in order to download easily my program and when i'm satisfied, I will use the minimum cabling with just the ATMega328P and decoupling capacitors. For now, I'm flashing my ATMega328P with the arduino board and an other ATMega328P configured in "flasher" with the program "Arduino as ISP", and after I put the new program ATMega328P instead of the other to have the hardware serial available, and do the exchange again to download a new program and so on.
Consider you cannot get your project working. Stating that it's so simple a schematic is not needed is not realistic.
I'm not trying to be sarcastic however from "out" side (aka the forum folks trying to help you) we hear "... I can't get this simple project working, but I know enough you don't need a schematic to help me solve this...."
The working of Serial depends on correct setting of MCU clock speed.
If you compiled your code as for 16 MHz and then use it with 8 MHz clock - of course the Serial won't works.
In order to solve this you need to set a 8 MHz F_CPU while compile the code in Arduino IDE.
Sorry but I don't understand. How can I do that and why I should do that ? I manage to make it work without doing that it (only on one on my two ATMega328P, don't know why), by adding decoupling capacitor lkie explian below above.
My problem now is that I want to download program by USB cable (USB A to USB B of the board), like this is a standard Arduino/Elegoo Uno Board, but I met this message :
stk500_getsync() attempt 4 of 10: not in sync: resp=0x35
With my ATMega328P provided with my Elegoo board, there is no problem, like my bootloader is not compatible ?