• AVR Freaks

C code DDR2 SDRAM check failure

Author
cbeif
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2012/05/09 14:28:30
  • Location: 0
  • Status: offline
2019/07/10 13:39:59 (permalink)
0

C code DDR2 SDRAM check failure

Can someone tell me if I am doing something wrong,
I am trying to get the internal 32MB SDRAM working on a PIC32MZ1025DAG169 chip.
So I wanted to write test code to see if I can actually read and write to the entire SDRAM.
 
uint16_t * __attribute__((coherent)) pddr;
int TestSDRAM( int32_t testsize )
{
    int32_t i;
    uint16_t test;
   
    printf("SDRAM memory test length WORDS=%d.\n",testsize) ;
    pddr = (uint16_t *)0x88000000; // this is the KSEG0 cacheable pointer to start of SDRAM
    i = testsize;
    while (i--)
    {
        *pddr++ = (uint16_t)0xbeef; // fill in SDRAM word with 0xBEEF
        test = (uint16_t)*(pddr-1); // do an immediate read back to make sure it works
                     
        if ( test != 0xbeef) // make sure we got back the correct data.
        {
            printf("SDRAM fast read FAILED i=%d test=0x%x pddr=%p\n",i,test,(pddr-1));
            break;
        }
    }
    
    // SANITY check, lets read back all of the data again to make sure its valid
    pddr = (uint16_t *)0x88000000;
    i = testsize;
    while (i--)
    {
        pddr+=1;
        test = (uint16_t)*(pddr-1);
               
        if ( test != (uint16_t)0xbeef)
        {
            printf("SDRAM slow read test FAILED i=%d test=0x%x pddr=%p\n",i,test,(pddr-1));
            return 1;
        }
    }
                           
    printf("SDRAM readback test PASSED\n");
    return 0;
}

 
If I call this function over and over like this.
 // SDRAM MEMORY TEST
    TestSDRAM(100000);
    TestSDRAM(100);
    TestSDRAM(1000);
    TestSDRAM(10000);
    TestSDRAM(20000);
    TestSDRAM(30000);
    TestSDRAM(40000);
    TestSDRAM(30000);
    TestSDRAM(20000);
    TestSDRAM(10000);
    TestSDRAM(1000);
    TestSDRAM(100);
    TestSDRAM(10);

 
Then I get this for an output
SDRAM memory test length WORDS=100000.
SDRAM slow read test FAILED i=99999 test=0xe000 pddr=88000000
SDRAM memory test length WORDS=100.
SDRAM readback test PASSED
SDRAM memory test length WORDS=1000.
SDRAM readback test PASSED
SDRAM memory test length WORDS=10000.
SDRAM readback test PASSED
SDRAM memory test length WORDS=20000.
SDRAM slow read test FAILED i=19999 test=0xe000 pddr=88000000
SDRAM memory test length WORDS=30000.
SDRAM slow read test FAILED i=29999 test=0xe000 pddr=88000000
SDRAM memory test length WORDS=40000.
SDRAM slow read test FAILED i=39999 test=0xe000 pddr=88000000
SDRAM memory test length WORDS=30000.
SDRAM slow read test FAILED i=29999 test=0xe000 pddr=88000000
SDRAM memory test length WORDS=20000.
SDRAM slow read test FAILED i=19999 test=0xe000 pddr=88000000
SDRAM memory test length WORDS=10000.
SDRAM readback test PASSED
SDRAM memory test length WORDS=1000.
SDRAM readback test PASSED
SDRAM memory test length WORDS=100.
SDRAM readback test PASSED
SDRAM memory test length WORDS=10.
SDRAM readback test PASSED

 
 
I don't understand how the the first test passes, if I read back data immediately,
but the next part fails, but only if I write more than 20000 words?
 
#1

0 Replies Related Threads

    Jump to:
    © 2019 APG vNext Commercial Version 4.5