Yes, just declare wordAddress as a pointer to volatile data:
void intelStartEraseBlock(volatile uint16_t *wordAddress) { ... }
The volatile keyword tells the compiler that the semantics must match the abstract virtual machine defined by C - in other words, every time you write a volatile variable, the code must actually be written to memory, and every time you read the volatile variable, the code should really read from memory.
The compiler cannot optimize these reads and writes, even if it considers them redundant.
Note that this should be pointer data declared volatile , not the pointer itself. Like the const keyword, this matters a lot. Since wordAddress itself is a variable on the stack, we do not care that its read / write actually goes on the memory stack, but we do care that the memory it points to (presumably some type of display I / O memory) is actually read / write.
source share