Unsuccessful Moteino R6 conversion to 8MHz

Started by RobinC, February 05, 2023, 03:21:34 AM

RobinC

Hi,

I have been messing with Moteinos for several years now, but have never previously got involved with programming fuses or flashing bootloaders. I have an existing project for which I want to further optimise battery life, so I am looking to convert it to 8MHz and run from 2xAA cells.

I have got myself this ISP https://www.pololu.com/product/3172 which seemed to me to be fairly comprehensive and well documented. I grabbed a new ( well unused .. ) Moteino R6 that I had in stock as a spare to practice on.

So far as I can tell I am able to successfully burn the fuses ( low=D2, High=DC, Ext=FE ) for 8Mhz operation and flash the "Dualoptiboot_v5.0_atmega328_8mhz_57600baud_BlinkD9.hex" bootloader using avrdude from Linux CLI. Having done so, I am not able to upload a sketch using an FTDI adapter at 57600 baud. I am able to restore normal operation by reburning the regular bootloader and changing the fuses back for 16Mhz operation. This pretty much convinces me that the ISP operations are good.

On further investigation I noticed that avrdude was failing at different points through the process of uploading a sketch at 57600baud, suggesting that the bootloader was functional but communication was unreliable. I then experimented with different non-standard baud rates which avrdude seems to accept and on one occasion successfully loaded a sketch with a baud rate of 57575. On running said sketch serial output was similarly garbled with occasional words rendered correctly when the baud rate was tweaked a bit in the terminal program.

This all suggests to me that the internal 8MHz RC Osc is unstable/inaccurate.

Anyone observed anything like this before ??
My usual assumption when things don't work is that I'm doing something wrong, but I cant figure out what it is here ...
Could it be a one off device fault ?
I don't have another spare moteino to try without experimenting on a production node ...

All suggestions/observations welcomed.

RobinC



RobinC

OK, so I have just been reading datasheets and discovered the OSCCAL register and Calibration bytes ....

Turns out 57600 is not the best baud rate for an 8MHz clock - 38400 is better it seems.

Not yet sure what to do with this information or if it is the issue at hand ...

RC

RobinC

OK, just to close this off ......
The problem was in fact an issue with the particular Moteino device. I was able to sucessfully convert another device (older Moteino R4) without issue.
It seems that there is a fair proportion of Moteino devices for which Serial UART communication fails using the internal 8MHz RC Oscillator. There is another thread to this effect at https://lowpowerlab.com/forum/moteino/convert-moteino-from-5v-to-3-3v-and-flash-issue/

I was able to get Serial communication to work at 38400 baud on the failing device by adjusting the OSCCAL register using a similar sketch to the one appearing at https://forum.arduino.cc/t/standalone-328p-and-uart/586797/4

RC

Felix

Or we could just do it all at 500kbaud regardless of the run frequency 16/8Mhz  :)