Originally Posted by
amaturequestion
Is there something I am doing wrong??
Yes, you did not dereference your pointers when you want to access what they point to. So this:
Code:
dev1 = *(__IO uint32_t*)(0x1FFFF7E8);
dev2 = *(__IO uint32_t*)(0x1FFFF7EC);
dev3 = *(__IO uint32_t*)(0x1FFFF7F0);
dev1 += dev2;
should have been:
Code:
*dev1 = *(__IO uint32_t*)(0x1FFFF7E8);
*dev2 = *(__IO uint32_t*)(0x1FFFF7EC);
*dev3 = *(__IO uint32_t*)(0x1FFFF7F0);
*dev1 += *dev2;
That said, I notice that you wrote:
Code:
one->x=dev1;
one->y=dev2;
This is also wrong because you need to dereference dev1 and dev2, but it looks like you don't need dev1 and dev2 to be parameters begin with. Rather, you could write:
Code:
void get_sample(sample *one)
{
uint32_t dev1;
uint32_t dev2;
dev1 = *(__IO uint32_t*)(0x1FFFF7E8);
dev2 = *(__IO uint32_t*)(0x1FFFF7EC);
dev1 += dev2;
one->x = dev1;
one->y = dev2;
UART_printf("%4x %4x\n", dev1, dev2);
}
Then in main:
Code:
get_sample(&one);
UART_printf("%4x %4x", one.dev1, one.dev2);
Originally Posted by
amaturequestion
Also thank you for your constant efforts.AMAZING
You're welcome