I have made 5 PCB with a standalone 328P with internal clock. I uploaded a simple "Hello World" sketch and use a USB adapter connected to RX/TX pin to see the result on terminal.
4 of them work ok, one aleays shows garbish on screen. Code is:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Hello world");
delay(1000);
}
After some trial and error i realise if i use Serial.begin(9200) and put my terminal @ 9200 or 9600 BAUD, i can see the hello world message correct. Other values mess output message.
First, make sure you actually remembered to set the fuses on the one that's not working (ie, maybe you forget to set the fuses for 8MHz, so it's still running at 1MHz). I would be interested to hear of an atmega328p that, at room temperature and 3.3~5v operating voltage, had an internal oscillator that was off enough for serial not to work (I've never encountered an individual chip that was - though such a chip would be entirely within spec).
Default (factory setting) Low Byte Fuse setting of ATmega328P is: 01100010; where the lower 3-bit has set the internal 8 MHz RC Oscillator. The CKDIV8 fuse bit is programmed by default; so, the operating frequency of the MCU is 1 MHz. The UART Section of the MCU can operate well at this frequency at Bd 9600 with 0.2% error which is same as that when the chip runs on 16 MHz external crystal at Bd 9600. Two chips of the same batch are working well and not the 3rd one -- is it possible that the internal RC oscillator of the 3rd one is way out due to manufacturing defect?
void setup() {
// put your setup code here, to run once:
//Serial.begin(57600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("oscal: ");
Serial.println(OSCCAL, HEX);
OSCCAL+=5;
delay(1000);
}
and i figure with OSCAL=30 UART works ok, so i add OSCAL=0x30 to setup(). The original (non working OSCAL was 45).
Now i wonder if this has impact in the code? These boards grab values from some sensors and send them to the cloud with a GPRS module...
Well that's good to know (that there do in fact exist, in the wild, boards where the internal oscillator isn't good enough for UART at 3.3~5v and room temperature)...
Also, 57600 is a weird baud rate with most Arduino boards - it's treated specially due to some historical oddity that they had to work around; for some reason they turn off UX2 mode for that baud rate specifically. It's probably more sensitive to clock variation at that specific baud rate.
There is no particular concern to running it like that (other than the fact that other individual specimens will require different OSCCAL value, if they need it set at all)