Changing device external crystal from 16Mhz to 8Mhz. Bootloader problems.

Hello all,

Perhaps I have missed something you guys can point out to me.

I have a working AT90CAN128 running the arduino bootloader and an external crystal of 16Mhz.

I would like to run this slower at 8Mhz.

So I updated the make file for the bootloader to set AVR_FREQ = 8000000L recompiled and programmed with a JTAG programmer.

The problem is the Ardunio IDE cannot connect to the bootloader, it times out every time.

I measured the pulse widths of the LED flash on pin A7 it is spot on 100ms just as with everything at 16Mhz. So I think the clock is configured correctly.

If I change back to 16000000L and recompile, program, swap crystal back everything works. Ardunio IDE connected to the bootloader fine.

The only thing I can think of is a problem with the UART configuration? Either it is not compensating for the change in AVR_FREQ, or the 8Mhz is not dividing down well???

Makefile:

# Makefile for ATmegaBOOT

at90can: TARGET = at90can128
at90can: MCU_TARGET = at90can128
at90can: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 -DDOUBLE_SPEED
at90can: AVR_FREQ = 8000000L 
at90can: LDSECTION  = --section-start=.text=0x1F000
at90can: $(PROGRAM)_at90can.hex

Bootloader:

/**********************************************************/
/* Serial Bootloader for Atmel megaAVR Controllers        */
/*                                                        */
/* tested with ATmega8, ATmega128 and ATmega168           */
/* should work with other mega's, see code for details    */
/*                                                        */
/* ATmegaBOOT.c                                           */
/*                                                        */
/*                                                        */
/* 20090308: integrated Mega changes into main bootloader */
/*           source by D. Mellis                          */
/* 20080930: hacked for Arduino Mega (with the 1280       */
/*           processor, backwards compatible)             */
/*           by D. Cuartielles                            */
/* 20070626: hacked for Arduino Diecimila (which auto-    */
/*           resets when a USB connection is made to it)  */
/*           by D. Mellis                                 */
/* 20060802: hacked for Arduino by D. Cuartielles         */
/*           based on a previous hack by D. Mellis        */
/*           and D. Cuartielles                           */
/*                                                        */
/* Monitor and debug functions were added to the original */
/* code by Dr. Erik Lins, chip45.com. (See below)         */
/*                                                        */
/* Thanks to Karl Pitrich for fixing a bootloader pin     */
/* problem and more informative LED blinking!             */
/*                                                        */
/* For the latest version see:                            */
/* http://www.chip45.com/                                 */
/*                                                        */
/* ------------------------------------------------------ */
/*                                                        */
/* based on stk500boot.c                                  */
/* Copyright (c) 2003, Jason P. Kyle                      */
/* All rights reserved.                                   */
/* see avr1.org for original file and information         */
/*                                                        */
/* This program is free software; you can redistribute it */
/* and/or modify it under the terms of the GNU General    */
/* Public License as published by the Free Software       */
/* Foundation; either version 2 of the License, or        */
/* (at your option) any later version.                    */
/*                                                        */
/* This program is distributed in the hope that it will   */
/* be useful, but WITHOUT ANY WARRANTY; without even the  */
/* implied warranty of MERCHANTABILITY or FITNESS FOR A   */
/* PARTICULAR PURPOSE.  See the GNU General Public        */
/* License for more details.                              */
/*                                                        */
/* You should have received a copy of the GNU General     */
/* Public License along with this program; if not, write  */
/* to the Free Software Foundation, Inc.,                 */
/* 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
/*                                                        */
/* Licence can be viewed at                               */
/* http://www.fsf.org/licenses/gpl.txt                    */
/*                                                        */
/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */
/* m8515,m8535. ATmega161 has a very small boot block so  */
/* isn't supported.                                       */
/*                                                        */
/* Tested with m168                                       */
/**********************************************************/

Wormfood's bit rate calculator (WormFood's AVR Baud Rate Calculator Ver. 2.1.1 ) says an 8MHz AVR has an error over 7% when trying to get 115200bps.

Try 38400...

Works at a lower speed, thanks!

Hi, I'm can I burn the bootloarder into atmega168 for use with 8mhz external crystal - through an Arduino board with 16mhz external crystal (standard Arduino) and USBTiny programer?

I have successfully burned the bootloader for 16mhz operation, but now would like to run my processor in my project at 8mhz and lower voltage requirement.

To shed more light on what I am doing is, I've created a minimal Arduino with bare essentials , I added a humidity sensor, LDR and RF TX that sends values every minute. I am running the whole thing on 3x AA and currently at 16mhz the Atmega hangs when the voltage drops to about 4.5v (it's minimal requirement at 16mhz) hence I would like to drop the voltage requirement to 3.3G by using 8mhz crystal.

BTW I wish to use the Arduino board only for assistance with boot lading and programing with the UBSTiny but then I will move the atmega168 to my PCB with 8mhz crystal.

Any help is much appreciated.

Peter.