Hi people.
The problem was solved and had nothing to do with Thumb mode, but with a
subtle caracteristic of the gnu compiler for ARM.
The Data Abort exeception was caused, not by a writing access to the
flash address space, but by an invalid read access from a misaligned
buffer.
The flash writing loop was:
for(i=0; i<(FLASH_PAGE_SIZE/4); i++)
{
*p++ = *buf++;
}
whith *p and *buf pointers to unsigned ints, as required, but *buf was
initialized with the address of a misaligned structure. The solution was
a declaration of an atribute of alignement:
struct _attribute_ ((packed, aligned (4)))
{
.....
} fine_struct;
and then we make
buf = (unsigned int *)((void *)&fine_struct);
Thanks for everybody.
Luiz Coelho
Luiz Coelho wrote:
> Hello.
> I have a Flash Write routine for the AT91SAM7XC256 that works fine
> when compiled in ARM mode but, when compiled in THUMB mode, generates
> a Data Abort exception when trying to write to the write page buffer.
> With this section of code removed, the program works fine in THUMB mode.
> The write access is done with 32 bits, as the datasheet states (item
> 20.1.3 Write Operations): "Writing 8-bit and 16-bit data is not
> allowed and may lead to unpredictable data corruption". Maybe the
> access to Flash should be done in 16 bits in THUMB mode?
> The base address for writing is calculated as:
> (pagenum * FLASH_PAGE_SIZE)+0x00100000, with FLASH_PAGE_SIZE = 256.
> I would apreciate some help with this problem. Thanks in advance.
>
> Luiz Coelho