sven
sven

Reputation: 1121

Using memcpy(...) to read Value(s) at a Physical Address

I need to read a value in an address at 0x2428 (flash memory of a MCU). How do I use memcpy to read the value?

 uint8_t *newData ,x;
 memcpy( newData, 0x2428, sizeof x);

But, I get

Error[Pe167]: argument of type "int" is incompatible with parameter of type "void const *

How should I fix the error?

Upvotes: 0

Views: 3840

Answers (1)

J. Murray
J. Murray

Reputation: 1450

You're trying to pass a memory address (0x2428) as the destination address of the memcpy operation, but the compiler simply sees it as a const int value (integer literal) when it is expecting a const void *. You will have to at the very least cast it to a data type of (const void *) 0x2428 to have a chance for this syntax to work.

Upvotes: 5

Related Questions