Bootloader (storing wrong data)

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

I'm using Atmega324P with avrgcc.

I have made a bootloader and I get a random FFFF in flash once in a while.

The data packet going to the microcontroller was verified and I am using crc8 for packet checks.

I have a feeling that when it stores the pages it is corrupting once in a while.

I use the following code to write a page.

	// Erase page
	boot_page_erase(address);
	while(boot_rww_busy())
	{
		boot_rww_enable();
	}

	// fill page buffer
	for(x=0; x < 128; x+=2)
	{
		boot_page_fill(address + x, ((((unsigned int)page[x+1])<<8) + ((unsigned int)page[x])));
	}

	// Write page
	boot_page_write(address);
	while(boot_rww_busy())
	{
		boot_rww_enable();
	}

	for (x=0; x<2000; x++); 

I am programming a 10k binary file to the uc and I will get 0 - 3 occurances of FFFF randomly in the flash.

Any ideas???

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I now disabled interrupts while programming. I think this fixed it.

It seemed random because of the randomness of the communication timing!