Hi, Not sure this is electrnoic or Programming but I had to pick one
I have a Atemga328P + 8mhz Resonator on a PCB, it has Rx/Tx + GND connected to a PIN header and a FTDI RS232-5v cable to the PC. fuses are set to an external 8mhz external crystal.
looking at the source code "complexity", I would explore more on the hardware side first given you compiled this with the IDE set to a 8MHz platform. If you compiled for a UNO at 16Mhz then of course that would be an issue
did you try switching the baud rate on the receiving end to see if by chance at 4800 or 19200 bauds you'd receive something that makes sense?
More info. Sorry I named the post "Nano" thats just because I use Nano's a lot and the 328P is used on Nano's. it's really just a Atmega328P MCU + 8mhz resonator and a serial pin header + few caps on the power supply.
that will compile with the flags -CC -mmcu=atmega328p -DF_CPU=16000000L and so all the libraries relying on knowing the processor speed will believe that you are running at 16MHz
possibly try with "Arduino Pro or Pro mini" and set to 8Mhz (it will say 3.3V but I don't think that matters)
OK that makes sense, however I compiled and whilst it did change the output it is still unreadable. after your post I looked at why I choose the 8Mhz as clearly on the schematics I find on the web it uses a 16mhz. when I went into the "Microchip Studio" the software I was going to use to program the code via ISP, the pull down for clock fuses only has options for 8Mhz, thsi I why I plumped for that speed, why is a 16mhz clock not an option on Microchip studio do you know?
I will purchase some 16mhz crystals ASAP but it would be nice to solve the 8mhz problem and Microchip Studio's lack of 16mhz.
OK, so I changed the rsonator for a 16mhz one, I'm using AVRdudess to flash the 328p, but yet again no 16mhz option on the fuses when you click on the weblink to configure the fuses.
Anyone know how to set the fuses for a 16mhz resoantor for a 328P
P.s. I have read the fuses from a brand new Nano and programmed my 329P with these fuses, still the serial port spews out garbage.
I've never done it but from the previous link one poster says
If you have a 16MHz crystal, then you want the "crystal or resonator" setting, NOT the "external oscillator" one. Not familiar with that specific unit, but most modern AVRs simply have a high frequency fuse setting for frequencies generally above something like 2MHz. The SUT bits control how many clock cycles have to go by before the MCU will actually begin running after power is applied. Generally, crystals take more cycles because they are slower to start up.
Still driving me nut's, confirmed clock speed on both my 328P and a nano being 16mhz with a scope. understand about this crystal vs ceramic oscillator and tried to figure out the fuses but nothing I do seans to change it.
The RS232 output whilst unreadable seems consistant.