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 */
/**********************************************************/