I've finally got myself a virgin ATMega328p and without uploading a bootloader, I've uploaded a simple variation of Blink and thought it was broken until I realised that because I hadn't set the fuses, the MCU was just using internal clock and running at 1MHz intead of 16MHz (I've included a crystal on my board).
So I'm thinking that if I set my fuses to the same as my ATMega328p Uno then I should be OK.
But I can't find what the bytes should be - could someone tell me please (I've given up trying to read them out from my Uno )
And of course, if the fuses should be different for a non-bootloader 16Mhz crystal clocked ATMega328p than my Uno, could I have those instead
Looking at your post #7 in that thread, you are setting the baud rate to 300 on the mcu but then you have to set the PC to 2400 to communicate with it. So the UART in the mcu is running 8x faster than it should be. This isn't a problem with the CLKSEL fuse bit, that would cause the mcu to run 8x slower instead.
Are you sure that you have F_CPU set correctly in the boards.txt file you are using? Do you also find that delay and delayMicroseconds calls also execute 8x faster than they should?
Looking at your post #7 in that thread, you are setting the baud rate to 300 on the mcu but then you have to set the PC to 2400 to communicate with it. So the UART in the mcu is running 8x faster than it should be. This isn't a problem with the CLKSEL fuse bit, that would cause the mcu to run 8x slower instead.
Are you sure that you have F_CPU set correctly in the boards.txt file you are using? Do you also find that delay and delayMicroseconds calls also execute 8x faster than they should?
Thanks for getting back to me Don.
From using the calculator I managed to get the baud correct with:
lfuse:w:0x77:m
(I know this is probably incorrect).
..and from messing about trying to set the fuses again I am back to the same issue of the baud reading out incorrectly and chasing my tail..
The following worked when I had the baud reading at the correct rate:
IDE does not upload
AVRDude upload via Arduino ISP works
Upload in IDE via Arduino ISP works
Serial feedback (TX-RX loop) works [328 bypassed]
Serial feedback via 328P works
Holding reset at various times before/during/on upload no dice
f_cpu=16000000L
I've double checked all my schematics, including the pull down 1k, 100nf cap between the 8u2 and the reset on the 328P-AU.
I have also removed and resoldered these components.
Could this be an issue with the 8u2?
I have managed to run the DFU many times with the same code I uploaded on to my R3 and this still uploads and works.
Is the baud rate mismatched only when you are uploading a program through the bootloader, or it is also mismatched when you do a Serial.begin followed by a Serial.print ?
Delay calls execute in the correct amount of time. So the clock is almost certainly running at the right speed.
To communicate with the serial port of the device, you have to set the PC to a baud rate 8x higher than the device is supposedly set to.
Therefore, either the PC software is at fault and is running at a baud rate 8x lower than you ask for, or the UART in your 328p-au is running at a baud rate 8x higher than you ask for. Can you connect to a standard Arduino at 2400 baud using the same board setting, to verify that the PC software is operating correctly?
I've just tried to communicate with my Arduino Uno at 300 baud, and it doesn't work. It works at higher baud rates. Maybe a bug in the Arduino software? Try a higher baud rate.
You might also like to upload the following sketch to see what the UART baud rate divisor is set to: