AW: BF532, problem accessing external interface HELP !!!!

Started by Bernhard Holzmayer December 6, 2004

> -----Ursprgliche Nachricht-----
> Von: [SMTP:]
> Gesendet am: Sonntag, 5. Dezember 2004 08:29
> An:
> Betreff: [adsp] BF532, problem accessing external interface HELP !!!!
> tmp = *pEBIU_AMGCTL;
> *pEBIU_AMGCTL = tmp | 0xE; //enable all AMS banks
> *pEBIU_AMBCTL1 = 0x2F422F42;
> pnt = (unsigned short *)0x2035A5A0; //ams3
> ptr = (unsigned short *)0x202A5A50; //ams2
> val1=0x5A5A;
> val2=0xA5A5;
> while (1)
> {
> *pnt = val1;
> val2 = *ptr;
> //*ptr = val2;
> }

Without having a BF532 around, just guessing from your code:

a C-compiler is allowed to optimize code in some ways, even if you don't select
optimization explicitely.

Depending on the environment: if val2 isn't used anywhere else, I'd expect the
compiler to "know" that the result is of no further use,
and therefore it would throw away the wole read command, because it's not
necessary to read a result which is not used furthermore.

At least try the following: define val2 as volatile like in the following
volatile unsigned short val2;

In this case, the read command should work, if no optimization is enabled.

However, this is not completely correct, since the compiler might even treat
*ptr as constant, because you didn't tell it, that the contents of ptr are
This might result in one single read command, having the result stored in a
temporary variable (register), and then written into val2 from there instead.

To get one read command at every loop, you'd have to define the ptr as pointing
to volatile contents, too:

ptr = (volatile unsigned short *) 0x202A5A50;