Writing flash of ATmega128

Hello everybody guys!

I have to program the flash of the ATmega128, so I wrote an assembly code including SPM instruction to do that; the writing of the flash is done using a software ad hoc on the PC, connected to the USART of the micro.

This is my problem: when I debug the code to write the flash with AVR studio everything is OK: the assembly function which execute the page write has a positive outcome and no errors are signaled!

But when I try to do that using the software connected to the micro USART it seemes to work properly after a while the page transfer stops and the flash is not written: I am pretty sure that the transfer of the data to the RAM is OK but the writing of the flash is not executed. I’ve already checked the lock bits and there is no lock on the SPM and LPM instructions.

Can anybody help me please?

Is it possible that for the debugger the procedure is OK but when I effectively try to do that it’s not working?

HELP MEEE! :smiley:

the BLIPS bootloader on the website avrfreaks.net projects section includes (1) a PC program to download programs to most any AVR including the mega128 and (2) assembly language source code for the bootloader for the AVR chip.

These allow you to download programs using a serial port link, wired or wireless. BLIPS also allows you to use a LAN connection by TCP/IP or UDP/IP, if you have an ethernet or WiFi to serial adapter.

The assembly language code in (2) can be used as an example of how to write the flash of AVRs and how to manage the RAMPZ bit for the mega128