I came across the follow line of code:
#define ADCA (*(volatile ADC_t*)0x200)
It is for embedded C code for an AVR microcontroller. ADC_t
is a union.
I know that (volatile ADC_t*)0x200
its a pointer to an absolute memory address but I am still not quite sure what the first *
means.
A pointer can also be stored in the form of a variable, to declare a pointer variable we also use the asterisk (*) operator. That said, by writing “int varX” we declare a variable named varX of type int, whereas writing “int * varY” declares a variable named varY which is a pointer to an integer.
Embedded systems use pointers all the time. I think the intended discussion point is that Embedded Systems sometimes have quite low amounts of memory. It's not usual in these systems to do the typical memory allocation ( malloc() / free() ) routines used in system/applications-level programming.
Pointers are variables that contain the address or location of a variable, constant, function, or data object. So a pointer isn't the actual data. It simply represents the address or location of the data that is being referenced.
An integer pointer (like addressOfDigit ) can only store the address of variables of integer type. int variable1; int variable2; char variable3; int *addressOfVariables; * – A pointer variable is a special variable in the sense that it is used to store an address of another variable.
That first *
dereferences the pointer. In other words ADCA
is the contents of the memory at 0x200
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With