I'm trying to write to memory using pointer as below, But it is writing to the unexpected address.
uint32_t* pointer = (uint32_t) (__MEMORY_BASE)
*(pointer+4) = data;
While using the below its working as expected,
uint32_t* pointer = (uint32_t) (__MEMORY_BASE + 4)
*pointer = data;
Can anyone please let me know, WHy I'm not able to use the first method to write to pointer address.
because of
pointerhas typeuint32_t *, this means that pointer + 1 = __MEMORY_BASE + 4, pointer + 4 = __MEMORY_BASE + 16, this is how pointer arithmetic works inC.