Problems with self-programming AVR flash

Dec 14, 2010 0 Replies

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

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required