typecast arm problem

Note: This was originally posted on 29th July 2009 at http://forums.arm.com

Hi


I use eclipse+yagarto+the exemple getting-started-project-1.3-at91sam7x-ek or RTOS "ARM7_AT91SAM7X256_Eclipse". I have a problem when I do this
char var1[2];
int short var2 = 0x1234;

*(int short*)var1 = var2

When I do the typecast the arm stop working if the address is odd. Can you tell me why the arm his not able to do that and how I can solve my problem, because with the Rabbit I was able to do that. I know I can use memcpy, but with this cast I save some CPU time.
Parents
  • Note: This was originally posted on 30th July 2009 at http://forums.arm.com

    When I do the typecast the arm stop working if the address is odd. Can you tell me why the arm his not able to do that and how I can solve my problem, because with the Rabbit I was able to do that. I know I can use memcpy, but with this cast I save some CPU time.


    Yes, in fact it is safer to avoid the optimization and use memcopy itself. We actually ran into a lot of trouble because we used this optimization. Initially we were working on Cortex M3 which supports unaligned access but later we had to port it to ARM7TDMI and then all hell broke loose. We had a really bad time trying to find each and every place where we had used this kind of typecast and replacing them with memcopys - so i'd suggest, use the time tested memcopy [:)]
Reply
  • Note: This was originally posted on 30th July 2009 at http://forums.arm.com

    When I do the typecast the arm stop working if the address is odd. Can you tell me why the arm his not able to do that and how I can solve my problem, because with the Rabbit I was able to do that. I know I can use memcpy, but with this cast I save some CPU time.


    Yes, in fact it is safer to avoid the optimization and use memcopy itself. We actually ran into a lot of trouble because we used this optimization. Initially we were working on Cortex M3 which supports unaligned access but later we had to port it to ARM7TDMI and then all hell broke loose. We had a really bad time trying to find each and every place where we had used this kind of typecast and replacing them with memcopys - so i'd suggest, use the time tested memcopy [:)]
Children
No data
More questions in this forum