I just found an insidious and disconcerting characteristic of the uVision3 ARM compiler V3.12a. I have inherited C code to migrate to the ARM processor. This C code uses unsigned char pointers quite liberally to pass the address of data back and forth. The code, of course, casts these generic unsigned char pointers to various data types to access the underlying data. I have found that if the unsigned char point happens to be pointing at a odd address and it is cast to a short type pointer (e.g., "*(SHORT*)p"), the compiler will resolve the address the previous even address. For a simplistic example, if the address of unsigned char *p happens to be 0x5 and the following code is executed:
unsigned char *p; ... *(unsigned short*)p = 0;
and a major re-write to change the way pointers are deployed is simply not an option Then I'm afried you've got yourself solidly stuck up that suspiciously brown creek without a canoe Absolutely. I can not count the times I have heard or seen "is simply not an option" and "make it work" about the same issue. I recall once in my younger days before I dared to say NO to the brass, I told management that some hardware had to be redone to make the software work. I spent 2 months telling management daily "I need new hardware" before they agreed. When, as a result of this, the project was delayed, it was, of course, my fault. The most often occuring issue in this respect is that someone will tell management "this will take 6 months" and management say "we need it in 3". The young engineer afraid of losing his job will say "OK" and finish the project in 9 months. Erik
and a major re-write to change the way pointers are deployed is simply not an option Well, if you are willing to risk losing a lot of time trying this because I neither can nor will guarantee that this will work: Do a global search on "long" and all derivatives thereof and insert an align statement before each and every one. Then do the same for short and int and whatever else you can find more than 8 bits long (such as float). Then, of course you will have to do the same before all arrays and structures and then finally use the debugger to find what you missed and fix that. Erik