I have a nice Ethernet bootloader for the ATMEG328 that's been working for several years (manages to take advantage of DHCP) and now I'm doing a design using an ATMEGA88 via UART. I thought this would be easy to port over. So far, I can jump from the main program to the bootloader ok as well as back to the main program after the bootloader times out.
But when I try to program it, it hangs up in some funky state when it goes to erase the flash. Reset the power and it works again but nothing was erased or re-programmed. I used the same bits of code that worked in the 328 - seems like this should be safe since they are on the same data sheet. (I did change the page size and all, but I haven't gotten to where that comes into play.) I'm using Codevision - I'm self taught in C so afraid to leave the compound.
Below is what I have in my main program, it goes off when it gets to page erase:
for(address = 0; address < 0x1800;address += 64)
_PAGE_ERASE( address );
In the in the flash.h and flash.c I have the following:
#define _PAGE_ERASE(addr) __AddrToZByteToSPMCR_SPM( (void flash *) (addr), 0x03 )
void __AddrToZByteToSPMCR_SPM(void flash *addr, unsigned char ctrl);
unsigned char __AddrToZByteToSPMCR_LPM(void flash *addr, unsigned char ctrl)
I know virtually nothing of assembly language, so it's a bit of black magic to me.
Any help appreciated.