gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > communication between arm 9 and arm 7

#173258 - sylvestersteele - Mon Mar 29, 2010 7:14 am

Hi,

I wrote a simple program- arm7 code is writing to address 0x02400123- just flipping numbers- if its 1 make it 2 and if its 2 make it 1.

arm9 is reading the same memory location and printing out that value- but the value never updates.

Why could this be?

I am using the non-cachable range of addresses so it look at the main mem every time.

I've also declared the variable volatile.

what could be the problem here?

Communicating through main memory might not be ideal etc- but I thought this was a simple thing to try and I want to get it working.

Thanks,
Sylvester

#173259 - sylvestersteele - Mon Mar 29, 2010 7:24 am

ARM 9

Code:
int main(void) {
//---------------------------------------------------------------------------------
   consoleDemoInit();
   volatile int* reg= (int *)0x02400123;
   
   while(1) {
   printf ("\nReg is: %d", *reg);
   
   swiWaitForVBlank();
   }

   return 0;
}



ARM7

Code:

int main(void) {
volatile int *copyToAddress= (int *)0x02400123;
*copyToAddress= 1;
   while (1){

      if (*copyToAddress==1){
      *copyToAddress=2;
      }
      else{
      *copyToAddress=1;
      }

   }
}



Sylvester

#173260 - Dwedit - Mon Mar 29, 2010 8:01 am

ARM9 has a cache, it will keep pulling the same value out of cache. Use the FIFO hardware instead, it can even generate interrupts, so you don't need to use polling.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#173266 - Mighty Max - Mon Mar 29, 2010 11:13 am

I second the advise from Dwedit.

However, the cache isn't the problem. The 0x024... mirror region does not have the cache bit set if it hasn't been changed.
The cache is only a problem if the cached mirror writes back to memory. (So you need to take care not to write anything to a cachline mapping to the same physical memory)

But:
The address you are using is is not aligned, you'll receive side-effects from that you have to take into account. Align it to 32bit or use byte access.
_________________
GBAMP Multiboot

#173273 - elhobbs - Mon Mar 29, 2010 1:27 pm

I think wintermute move the uncached memory region to be compatible with dsi - since the old region fell withing the 16MB range used by the dsi. there is a function to convert an address to the uncached mirror - the name escapes me at the moment...