So i've been working through the "Make: AVR Programming" book, and there is a section (Section 5 with the UART sample program) that I was getting really goofy Serial data back from the AVR. I did some digging and it looked like it was probably some mismatch with what my CPU frequency was (For reference the SE question was asked here: Serial Output returns wrong ASCII)
Anyways, the book itself doesn't use a 16mhz Crystal and I had probably bought this atmega with a preloaded bootloader or something........because i've been programming it with AVRDUDE and the 16mhz Crystal for the past programs. Taking out the Oscillator gives the initialization failed, rc=-1 error.
So my guess was..ok I need to set the efuse (or maybe it was lfuse?), since everything lined up besides that one (it was showing 0x07 and I was trying to set it to 0xFF as shown by the "Default" Atmega328p fuse calculator: http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega328p)
Despite that I would get an error here back from AVRDUDE:
avrdude: verification error, first mismatch at byte 0x0000 0xff != 0x07
So im probably a bit lost. FWIW the "UART.c" file is defined here: https://github.com/hexagon5un/AVR-Programming/blob/master/AVR-Programming-Library/USART.c(The other code is in chapter 5 "serialLoopback.c"). Also I made sure baudrate was 9600. But from looking at that other post....im wondering that it's maybe my CPU Frequency was off?
Basically I think I need to make it where:
- I can program without the Crystal , since the book uses the internal crystal (Im using the Pocket AVR programmer from Sparkfun: https://www.sparkfun.com/products/9825)
- Figure out what I need to set my CPU Frequency to?
- Figure out why I can't set the fuse manually
I admit that I am still new, so fuses im probably not as experienced on. But this is just what i've tried from my research.