Problems with self-programming AVR flash

Hello,

I am using an ATmega324PA in a new application and want to provide IAP capability, i.e. there is a loader that can update the application by serial communication.

The IAP loader is located at the top of the flash memory (in the RWW section), and exactly follows the description given in the data sheet and some application notes to erase and write the flash.

However, the SPM command simply does nothing - neither does ist erase a flash page, nor does it program any data into the flash. There isn't any delay when programming, either - SPMEN becomes inactive immediately again after SPM has been issued.

I have looked at several (supposed to work) code samples, and I think the accesses and their sequence is exactly identical. What could be wrong?

Here's the code (IAPBase is at word address 0x1E00):

--

; Erase Flash from 0x0000 up to IAP loader:

		...
		clr	ZL
		clr	ZH		; start at 0
EraseLoop:	ldi	r16,(1
Reply to
Tilmann Reh
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.