Writing to FLASH

You would think that writing to FLASH would not be such a big thing. But it took several┬ádays to accomplish. The first issue is that your reprogram code can’t live in the same FLASH as you want to program. With only one bank of FLASH that meant running the code from RAM. That took a fair amount of learning including a jaunt into assembler and GLU linker file syntax. Next was writing the device driver to use the SAM7’s EFC peripheral. This was quite easy since a good shell exists in the ATMEL supplied library. The real problem came from trying to understand the sequence of events to write to FLASH. Get this, you need to write the data to the desired addresses inside a page AND THEN request a reprograming. Seems backwards to me and from previous experience. The other issue was a bug I found when I turned off interrupts as needed during the reprograming. When I turned them back on, any interrupts that occured during the outage where not queued. I therefore lost my timer tick interrupt and the OS stoped running. Turns out You need to use level triggering on interrupts and not edge. Strange.

This entry was posted in ARM, AVC. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Blue Captcha Image
Refresh

*