Hi,
I am trying to write a bootloader for the ATmega64 using avrgcc. As a
small test to see if I could change the program memory I tried out the
following code:
[code]
#include <avr/interrupt.h>
#include <avr/boot.h>
#include <avr/io.h>
int main(void)
{
#define ADDRESS 0x1000UL
// debug pin
DDRE = 0xff;
PORTE = 0xff;
// Erase page.
boot_page_erase((unsigned long)ADDRESS);
while(boot_rww_busy())
{
boot_rww_enable();
}
// Write data to buffer a word at a time. Note incrementing address
// by 2. SPM_PAGESIZE is defined in the microprocessor IO header
file.
for(unsigned long n = 0; n < SPM_PAGESIZE; n += 2)
{
boot_page_fill(ADDRESS + n, n);
}
// Write page.
boot_page_write((unsigned long)ADDRESS);
while(boot_rww_busy())
{
boot_rww_enable();
}
for(;;)
{
PORTE ^= 0xff;
}
return 0;
}[/code]
The code is located at address 0x7C00, and the following values have
been set
BOOTSZ = 01
BOOTST = 0
No lock bits have been set.
I have verfied that the program is running by looking at the toggling
of PORTE.
I would expect the program memory to change, but when I read the memory
back via the ISP port all memory values except the values where the
booloader is located equals 0xff..
Could anybody please point out what I am doing wrong here? I have run
out of ideas and would appreciate some input.
Thanks,
Richard
_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list