FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [July 2009 Threads] RTOS+ arm7 typecast problemPosted by Joel cote on July 29, 2009 Hi,
I use eclipse+yagarto+the exemple 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 and go in data abort of boot.s. Can someone 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.
thank
RE: RTOS+ arm7 typecast problemPosted by Ben on July 29, 2009 sounds like an alignment problem. var1 is probably at an odd address which is fine for byte access but not for 16/32 bit access
Ben
RE: RTOS+ arm7 typecast problemPosted by Ben on July 29, 2009 have you tried the reverse ?
int short var2 = 0x1234; char* var1;
var1 = (char*)&var2;
Ben
RE: RTOS+ arm7 typecast problemPosted by Joel cote on July 29, 2009 yes I have the problem only when the var1 have a odd address, how can I solve that? No I didn't tried the inverse, because in you exemple var1 is only a ptr, I want the value to be copied and be able to modify var2 without modify the value of var1
Joël
RE: RTOS+ arm7 typecast problemPosted by Ben on July 29, 2009 You could try using the aligned attribute
http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html
RE: RTOS+ arm7 typecast problemPosted by Joel cote on July 29, 2009 That doesn't work because in my real projet i'm in a structure (who is packed to be sure no memory space is left between two variable), So if I have this kind of structure var1[2]; var2; var3[2]; and I use var3 it is sure that the address of var3 is odd and that doesn't work on the arm, but I don't know why because on the rabbit i'm am able to do that
RE: RTOS+ arm7 typecast problemPosted by Ben on July 29, 2009 Assuming the structure has to be packed and you can't change the order of the structure elements you will have to copy the short int a byte at a time.
If you can change the order of the elements then delcare var3 after var 1 and both will probably be aligned on an even address, assuming the structure is aligned that way.
This is not really the correct forum for discussing this as it is not a problem with FreeRTOS or related in anyway to it. You would still have your problem even if you used no RTOS.
RE: RTOS+ arm7 typecast problemPosted by Joel cote on July 29, 2009 Do you know better forum where I can post ? I tried sparfun and atmel
thank
RE: RTOS+ arm7 typecast problemPosted by Adam Turowski on July 29, 2009 Thisshould work:
char var1[2]; int short var2 = 0x1234; var1[1] = (char) (var2 & 0xFF); var1[0] = (char) (var2 >>8);
Maybe not most effective, but it will work? BTW why are you doing such ugly casting anyway?
RE: RTOS+ arm7 typecast problemPosted by Joel cote on July 29, 2009 I know this work, but it's take more time to the cpu to do it. Why did you find this cast ugly, I find it so beautiful :P. With this cast the cpu copy the value in one shot and this fast when you have to do many.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|