?? sdram.c
字號:
////////////////////////////////////////////////////////////////////////////
//
// Program to check the functionality of core accesses to SDRAM
// device
//
// - PRD
//
#ifdef __ADSP21375__
#include <Cdef21375.h>
#include <def21375.h>
#elif __ADSP21369__
#include <Cdef21369.h>
#include <def21369.h>
#endif
//////////////////////////////////////////////////////////////////////////////
//
// COMMON DEFINES
//
//////////////////////////////////////////////////////////////////////////////
#ifdef __ADSP21369__
#define SDRAM_START 0x08000000 // start address of SDRAM
#define SDRAM_SIZE 0x00100000 // size of SDRAM in 32-bit words. (i.e. 1M x 32)
#elif __ADSP21375__
#define SDRAM_START 0x00200000 // start address of SDRAM
#define SDRAM_SIZE 0x00400000 // size of SDRAM in 32-bit words. (i.e. 1M x 32)
#endif
//////////////////////////////////////////////////////////////////////////////
//
// function prototypes
//
//////////////////////////////////////////////////////////////////////////////
void InitPLL(void);
int TEST_SDRAM(void);
//////////////////////////////////////////////////////////////////////////////
//
// stand alone test jig
//
//////////////////////////////////////////////////////////////////////////////
#ifdef _STANDALONE_ // use this to run standalone tests
int main(void)
{
int bPassed = 0;
//InitPLL();
bPassed = TEST_SDRAM();
return 0;
}
#endif //#ifdef _STANDALONE_
//////////////////////////////////////////////////////////////////////////////
// int TEST_SDRAM(void)
//
// PURPOSE: Test the SDRAM
//////////////////////////////////////////////////////////////////////////////
int TEST_SDRAM(void)
{
volatile unsigned int *pDst;
int nIndex = 0;
int bError = 1; // returning 1 indicates a pass, anything else is a fail
int n;
// Note that MS2 & MS3 pin multiplexed with flag2 & flag3.
// MSEN bit must be enabled to access SDRAM, but LED8 cannot be driven with sdram
// Note that MS2 & MS3 pin multiplexed with flag2 & flag3
// Programming the mutliplexed pin as MS2
*pSYSCTL |= MSEN;
// Mapping Bank 2 to SDRAM
// Make sure that jumper is set appropriately so that MS2 is connected to
// chip select of 16-bit SDRAM device
#ifdef __ADSP21369__
*pEPCTL |= B2SD;
#elif __ADSP21375__
// Mapping Bank 0 to SDRAM
*pEPCTL |= B0SD;
#endif
//*pEPCTL &= (~(B0SD|B1SD|B3SD));
// write incrementing values to each SDRAM location
for(nIndex = 0, pDst = (unsigned int *)SDRAM_START; pDst < (unsigned int *)(SDRAM_START + SDRAM_SIZE); pDst++, nIndex++ )
{
*pDst = nIndex;
}
// verify incrementing values
for(nIndex = 0, pDst = (unsigned int *)SDRAM_START; pDst < (unsigned int *)(SDRAM_START + SDRAM_SIZE); pDst++, nIndex++ )
{
if( nIndex != *pDst )
{
bError = 0;
break;
}
}
// write all FFFF's
for(nIndex = 0xFFFFFFFF, pDst = (unsigned int *)SDRAM_START; pDst < (unsigned int *)(SDRAM_START + SDRAM_SIZE); pDst++ )
{
*pDst = nIndex;
}
// verify all FFFF's
for(nIndex = 0xFFFFFFFF, pDst = (unsigned int *)SDRAM_START; pDst < (unsigned int *)(SDRAM_START + SDRAM_SIZE); pDst++ )
{
if( nIndex != *pDst )
{
bError = 0;
break;
}
}
// write all AAAAAA's
for(nIndex = 0xAAAAAAAA, pDst = (unsigned int *)SDRAM_START; pDst < (unsigned int *)(SDRAM_START + SDRAM_SIZE); pDst++ )
{
*pDst = nIndex;
}
// verify all AAAAA's
for(nIndex = 0xAAAAAAAA, pDst = (unsigned int *)SDRAM_START; pDst < (unsigned int *)(SDRAM_START + SDRAM_SIZE); pDst++ )
{
if( nIndex != *pDst )
{
bError = 0;
break;
}
}
// write all 555555's
for(nIndex = 0x55555555, pDst = (unsigned int *)SDRAM_START; pDst < (unsigned int *)(SDRAM_START + SDRAM_SIZE); pDst++ )
{
*pDst = nIndex;
}
// verify all 55555's
for(nIndex = 0x55555555, pDst = (unsigned int *)SDRAM_START; pDst < (unsigned int *)(SDRAM_START + SDRAM_SIZE); pDst++ )
{
if( nIndex != *pDst )
{
bError = 0;
break;
}
}
// write all 0000000's
for(nIndex = 0x00000000, pDst = (unsigned int *)SDRAM_START; pDst < (unsigned int *)(SDRAM_START + SDRAM_SIZE); pDst++ )
{
*pDst = nIndex;
}
// verify all 00000's
for(nIndex = 0x00000000, pDst = (unsigned int *)SDRAM_START; pDst < (unsigned int *)(SDRAM_START + SDRAM_SIZE); pDst++ )
{
if( nIndex != *pDst )
{
bError = 0;
break;
}
}
// butterfly test. Write incrementing values to beginging and end of SDRAM
volatile unsigned int *pStart = (volatile unsigned int *)SDRAM_START;
volatile unsigned int *pEnd = (volatile unsigned int *)(SDRAM_START + SDRAM_SIZE)-1;
for(nIndex = 0; nIndex < (SDRAM_SIZE/2); nIndex++ )
{
*pStart = nIndex;
*pEnd = (SDRAM_SIZE - nIndex);
pStart++;
pEnd--;
}
// verify butterfly test values
pStart = (volatile unsigned int *)SDRAM_START;
pEnd = (volatile unsigned int *)(SDRAM_START + SDRAM_SIZE)-1;
for(nIndex = 0; nIndex < (SDRAM_SIZE/2); nIndex++ )
{
if( nIndex != *pStart )
{
bError = 0;
break;
}
if( (SDRAM_SIZE - nIndex) != *pEnd )
{
bError = 0;
break;
}
pStart++;
pEnd--;
}
return bError;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -