Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 11.3 Access to registers or memory
#2
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.
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>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)