cancel
Showing results for 
Search instead for 
Did you mean: 

Aligment error (PGAERR) on FLASH write. Error UNDEFINSTR joins the party

Tobe
Senior III

I dont know why this error happens. It is aligned as 0x0800F800.

Not only this, but i get a hardfault (UNDEFINSTR) error too, while printing the above error with the following:

printf("Error writeFLASHDoubleWord FLASH->SR: %02X", READ_REG(FLASH->SR));

1 ACCEPTED SOLUTION

Accepted Solutions

You are spot on. I did not think about how big a page actually is ;-).

I put it now at the end to not get a problem again. But i found out, that after erasing pages, my writing does not work anymore. If i comment out the erase, i can write the flash. How can the erase prevent me from writin?

erase blocks write.jpg

View solution in original post

9 REPLIES 9

You can read FLASH->SR directly, and its not at 0x800F800

Your error is coming from something else. Decompose the Hard Fault, presenting those registers and the machine instructions that are faulting, so it might be more apparent what the actual issue is.

The printf() doesn't look intrinsically wrong. Are you perhaps deleting the code/data that relate to the instruction, the library, the string?

A double word would need to be on an 8-byte boundary, and the content properly erased.

Going to need better presentation and context to understand why this is failing.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

You are spot on. I did not think about how big a page actually is ;-).

I put it now at the end to not get a problem again. But i found out, that after erasing pages, my writing does not work anymore. If i comment out the erase, i can write the flash. How can the erase prevent me from writin?

erase blocks write.jpg

>>How can the erase prevent me from writing?

It didn't complete yet?

There's some pending error?

 

Hard to tell anything from screen shot code fragment. Need to see output and sequences from an instrumented process. Best not to single-step in debugger, or dwell on the peripheral view. Print out info about the stages, and the register in hex at each point. Decimal not helpful.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I dont do single step as i know of the problems.

But i found my problem: i did not clear PER and PNB after erase, which gave me troubles. After findind out you can write some flash without erase, i went like this. But it seems that it does not work any kind of predictable.

Piranha
Chief II

On these devices after erase every 64-bit cell can be written just once and in addition one can always invalidate the cell by writing zeros to it. All of it is explained in the reference manual.

I was having some memory about invalidating, but could not find the part in the manual again...

But with playing around with it, i can truly confirm that.

Piranha
Chief II

RM0440 Rev 7 section 5.3.7 tells it in the second sentence...

No, i think it was somewhere else. It is in general the case: with addresses that you have not programmed before, you can only write 0x0.

What "no"? I showed where it is written. If it's also written in some other place... so what? And how many times un how many places it must be written for you to finally read it? Zero is the only value that can be written to addresses that have been programmed previously!