Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pointer made from an integer in C on an embedded platform

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.

like image 565
Hector Avatar asked Sep 22 '11 22:09

Hector


People also ask

How do I create a pointer in embedded C?

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.

Are pointers used in embedded C?

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.

What is pointers in embedded system?

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.

What is pointer to integer in C?

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.


1 Answers

That first * dereferences the pointer. In other words ADCA is the contents of the memory at 0x200.

like image 75
David Heffernan Avatar answered Oct 26 '22 08:10

David Heffernan