28-03-2014, 09:21 AM
Another solution is, to use the following code. But then I get a violation of MISRA C2004 rule 17.4 Pointer arithmetic should not be used.
So I tried to eliminate this error... and came back to rule 11.3:
Perhaps I should not ask "how to eliminate the violation" but "which violation is the least problematic violation"?
Code:
register uint32_t *address = ANY_RAM_ADDRESS;
register uint32_t pattern = ANY_PATTERN;
*(volatile uint32_t *)address = pattern;
address += 1; /* violating rule 17.4 */
So I tried to eliminate this error... and came back to rule 11.3:
Code:
address = (uint32_t)p_memory;
address += sizeof(uint32_t);
p_memory = (uint32_t *)address;
Perhaps I should not ask "how to eliminate the violation" but "which violation is the least problematic violation"?
<t></t>