OK, so I've got some code done now for modifying flash from a SRAM variable. The SRAM variable is a 128 byte array, the size of a page in the ATMEGA16, which I am using.
The SPM instruction seems to get setup correctly, and all the pointers seem to be pointing to the right place, but it doesn't want to write a page.
I have tried this in AVR simulator V4.07, and on an actual device running some other code aswell. No flash gets modified.
One thing that does confuse me is the temporary buffer for the SPM instruction which you need to fill with the data before executing a page write.
I have the Z pointer pointing to the word in flash that I want to update when going through the temporary buffer fill part, but something doesn't ring right there? Is this wrong?
Also, I presume that the latest AVR studio 4 does deal with the SPM instruction OK?
I have attached some example code of the routines that are not working properly yet. Any help with this would be great.
Many Thanks, Brian Sidebotham.