Yes, the exact code works well. But there is a small difference between the code and my implementation. I am not using a memory address directly. I am using an array of unsigned char to allocate the memory space. And this gave me a Hard Fault.
And I figured out the root cause finally. It's due to the alignment error. The conversion from unsigned long to float must be byte aligned. And it seems the array of unsigned char is not aligned with a float value. I changed array defintion to float type. Then it works.
I tried to add "__attribute__ ((aligned(4)))" after the structure defintion. But it didn't work too. I don't know the reason.
Anyway this can be closed.
Thanks!
Rick