Bootloader question

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello guys have a small bootloader problem.
I have a simple program in the bootloader section that is toggleing a pin on a port.
When i put it in the atmega128 it works perfectly.
So now i did the same program only this time another pin is toggled in a timer interrupt.
So whan i start the atmega128 it runs if i do not turn on the global interrupt
but wen i do turn on the globale interrupt it will hang.

But my vector table is in the boot section I set the IVSEL bit too so what is the problem???
It seems that the vectors point to the correct adress (i'm not so good in assembly I know same on me).
I used -Wl,-Ttext=0x1e000 to move all the code to the boot section. I set the BOOTRST fuse and the BOOTSZ fuse.

So i can only conclude that some how my vector adress is still not correct.

I know the code works becuase if i put it on flash adress 0x0000 it works.

What do you guys think is the problem.

#include 
#include 
int main(void)
{
	unsigned int i;
	unsigned char toggle = 0;
	/* Enable change of interrupt vectors */
	MCUCR = (1 << IVCE);
	/* Move interrupts to boot flash section */
	MCUCR = (1 << IVSEL);
	
	/* set led pins ect */
	DDRG = (1 << PG4 | 1 << PG3);
	PORTG &= ~((1 << PG3) | (1 << PG4));
	
	/* Init timer */	
	TIMSK |= (1 << OCIE0);
	OCR0 = 1;
	TCCR0 = (1 << WGM01) | (1 << CS00) | (1 << CS01) | (1 << CS02);	
	
	
	sei();	
	
	while(1)
	{
		if(i == (unsigned int)60000)
		{
			if(toggle)
			{
				PORTG |= (1 << PG4);		
			}
			else
			{
				PORTG &= ~(1 << PG4);		
			}
			toggle ^= 1;	
			i =0;
		}
		i++;
	}
}

ISR(TIMER0_COMP_vect)
{	
	static unsigned int heartbeat = 0;
	static unsigned char toggle = 0;
	
	if(heartbeat >= 800)
	{
		if(toggle)
		{
			PORTG |= (1 << PG3);		
		}
		else
		{
			PORTG &= ~(1 << PG3);		
		}
		toggle ^= 1;		
		heartbeat = 0;
	}
	heartbeat++;	
}

Hexdump:

:020000021000EC
:10E000000C9446F00C9465F00C9465F00C9465F05B
:10E010000C9465F00C9465F00C9465F00C9465F02C
:10E020000C9465F00C9465F00C9465F00C9465F01C
:10E030000C9465F00C9465F00C9465F00C94B8F0B9
:10E040000C9465F00C9465F00C9465F00C9465F0FC
:10E050000C9465F00C9465F00C9465F00C9465F0EC
:10E060000C9465F00C9465F00C9465F00C9465F0DC
:10E070000C9465F00C9465F00C9465F00C9465F0CC
:10E080000C9465F00C9465F00C9465F011241FBE9F
:10E09000CFEFD0E1DEBFCDBF11E0A0E0B1E0EEE018
:10E0A000F2EE01E00BBF02C007900D92A030B10765
:10E0B000D9F711E0A0E0B1E001C01D92A330B10793
:10E0C000E1F70E9467F00C9404F10C9400F0CF93F8
:10E0D000DF93CDB7DEB723970FB6F894DEBF0FBE40
:10E0E000CDBF1982E5E5F0E081E08083E5E5F0E071
:10E0F00082E08083E4E6F0E088E18083A5E6B0E09A
:10E10000E5E6F0E08081877E8C93A7E5B0E0E7E567
:10E11000F0E0808182608C93E1E5F0E081E0808333
:10E12000E3E5F0E08FE080838A819B812AEE8036F0
:10E130009207C1F48981882341F0A5E6B0E0E5E6C5
:10E14000F0E0808180618C9307C0A5E6B0E0E5E651
:10E15000F0E080818F7E8C93898191E0892789838B
:10E160001B821A828A819B8101969B838A83DCCFE2
:10E170001F920F920FB60F9211242F938F939F939C
:10E18000AF93BF93EF93FF93CF93DF93CDB7DEB7FA
:10E19000809101019091020123E080329207E8F022
:10E1A00080910001882341F0A5E6B0E0E5E6F0E0CB
:10E1B000808188608C9307C0A5E6B0E0E5E6F0E0DA
:10E1C0008081877F8C938091000191E089278093E3
:10E1D00000011092020110920101809101019091C1
:10E1E000020101969093020180930101DF91CF918A
:10E1F000FF91EF91BF91AF919F918F912F910F90D0
:0EE200000FBE0F901F9018950C9406F1FFCFE3
:040000031000E00009
:00000001FF
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fix the problem by writing an own make file.