hexagon5un / AVR-Programming

Code examples for the book "Make: AVR Programming"
http://littlehacks.org/AVR-Programming
MIT License
725 stars 340 forks source link

Serial Loopback with ATMega328p-pu #34

Open tenderlove opened 6 years ago

tenderlove commented 6 years ago

Hi,

I'm trying to get the serial loopback from Chapter 5 working with my ATMega328p-pu chip. I've tried changing F_CPU as well as updating the fuses, but it seems that no matter what I change the fastest I can get is 3600 baud. I'm not sure if I'm doing something wrong, or if 3600 baud is the fastest this chip can do (without an external crystal).

Thanks in advance!

tenderlove commented 6 years ago

Just to be specific, I am able to get the chip to echo characters back to me, I just have to set the baud on my local client to 3600 for the characters to be correct. It doesn't matter what baud I set in the Makefile, it's always 3600 on my client. I've verified it's actually recompiling the code and reflashing the chip. I've also tried changing the fuses. If I manually define USE_2X in my source, it does impact the speed, it's just stuck at 19200 rather than 3600.

tenderlove commented 6 years ago

I've ended up setting F_CPU= 8000000UL and setting LFUSE = 0xE2 to disable the clock divider. This let me use 19200 for the baud without manually defining USE_2X. However, it doesn't seem to matter what I set BAUD to, I always get 19200 speeds.