in my project am using 5 analog input and i have to take avg of that 5 input.. by means of adc i convert that 5 analog input into digital.. now those digital value stored in following address..
0x200
0x202
0x204
0x206
0x208
in order to take the avg of this 5 input i have read that content of above memory addrees
any body will help me to read this content of memory by means of pointer.. pls send the any sample codes.
The question is not clear.
Do you need to read a specific memory location?
Or these positions are in facts ADC registers mapped into memory space? In the second case, if you use C you normally can access peripheral registers via predefined symbolic names.
in my project am using 5 analog input and i have to take avg of that 5 input.. by means of adc i convert that 5 analog input into digital.. now those digital value stored in following address..
0x200
0x202
0x204
0x206
0x208
in order to take the avg of this 5 input i have read that content of above memory addrees
any body will help me to read this content of memory by means of pointer.. pls send the any sample codes.
I'm afraid you're close srkanthsamaga, but no cigar.
The line in question:
Code:
ptr = 0x200;
Assigns an integer to a pointer to an integer, this will result in a compiler error. You must explicitly indicate to the compiler that the value 0x200 is an address to an integer type:
Code:
ptr = (int *)0x200;
This is of course assuming the value at location is indeed of size integer, 10-bit, 12-bit or 16-bit ADC value, and not of size char, 8-bit value.
It has to be like this Value += *ptr;
You won't get the average of 5 if you use Value = *ptr; Because when no of values becomes 5 Ptr will have 208,*208(Value at that address) will be saved in Variable Value..
Hence change the code to be it has to be Value += *ptr;.
Note: Make sure to use (float) *Ptr or (int) *ptr according to the data which has to be read from memory location,similarly Variable Value has to changed..To get more accurate results....