DSP6748DDR2的测试程序
2019-07-13 12:59 发布
生成海报
main_ram.c
//-----------------------------------------------------------------------------
// file main.c
// rief implementation of main() to test bsl drivers.
//
//-----------------------------------------------------------------------------
#include "stdio.h"
#include "types.h"
#include "evmc6748.h"
#include "evmc6748_timer.h"
#include "evmc6748_i2c.h" #include "test_ram.h"
//-----------------------------------------------------------------------------
// Private Defines and Macros
//-----------------------------------------------------------------------------
// uncomment this define if running without gel initialization.
// #define NO_GEL (1)
//-----------------------------------------------------------------------------
// Static Variable Declarations
//-----------------------------------------------------------------------------
// Private Function Prototypes
//----------------------------------------------------------------------------
// Public Function Definitions
//-----------------------------------------------------------------------------
// rief entry point for bsl test code.
// param none.
//
eturn none.
//-----------------------------------------------------------------------------
int main(void)
{
uint32_t results = 0;
#if NO_GEL
EVMC6748_init(); EVMC6748_initRAM();
#endif
// init the us timer and i2c for all to use.
USTIMER_init();
I2C_init(I2C0, I2C_CLK_400K);
// TEST RAM
//---------
results = TEST_ram();
printf("
");
if (results != ERR_NO_ERROR)
printf("
********** C6748 TEST FAILED **********
");
else
printf("
********** C6748 TEST PASSED **********
");
}
test_ram.c
//-----------------------------------------------------------------------------
// file test_ram.c
// rief implementation of C6748 ram test.
//
//-----------------------------------------------------------------------------
#include "stdio.h"
#include "types.h"
#include "evmc6748.h" #include "evmc6748_ddr.h"
#include "test_ram.h"
//-----------------------------------------------------------------------------
// Private Defines and Macros
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Static Variable Declarations
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Private Function Prototypes
//-----------------------------------------------------------------------------
uint32_t verifyAddrDataBus(uint32_t in_begin_addr);
uint32_t verifyPattern(uint32_t in_begin_addr, uint32_t in_num_bytes);
//-----------------------------------------------------------------------------
// Public Function Definitions
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// rief tests the external ddr. this test assumes the code is not being
// executed from external ddr, so makes not attempt to maintain data.
//
// param none.
//
//
eturn uint32_t
//-----------------------------------------------------------------------------
uint32_t TEST_ram(void)
{
uint32_t rtn = 0;
printf("------------------------------------------------------------
");
printf(" C6748 RAM Test
");
printf("Test Description
");
printf("----------------
");
printf("this code verifies the mDDR address bus and writes/verifies
");
printf("data patterns to the mDDR.
");
printf("------------------------------------------------------------
");
//-------------------------------------
// initialize the required bsl modules.
//-------------------------------------
// nothing to init for this test. ram was taken care of in gel or main.
//--------------
// execute test.
//--------------
printf("
Execute Test
");
printf("------------
");
/*
printf("--- Test address and data bus ---
");
rtn = verifyAddrDataBus(DDR_MEM_BASE);
if (rtn != ERR_NO_ERROR)
{
return (rtn);
}
else
{
printf(" address/data bus test passed
");
}
*/
printf("--- Test data pattern ---
");
rtn = verifyPattern(DDR_MEM_BASE, DDR_MEM_SIZE / 2);
if (rtn != ERR_NO_ERROR)
{
return (rtn);
}
else
{
printf(" data pattern test passed
");
}
return (ERR_NO_ERROR);
}
//-----------------------------------------------------------------------------
// Private Function Definitions
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// tests the address and data lines.
//-----------------------------------------------------------------------------
uint32_t verifyAddrDataBus (uint32_t in_begin_addr)
{
uint32_t offset;
uint32_t test_data = 0;
uint32_t *test_addr = (uint32_t *)in_begin_addr;
for (offset = 1; offset <= 0x8000; offset <<= 1)
{
// write test data to the test address.
*test_addr = test_data;
*(test_addr + offset) = ~test_data;
// verify the data is correct.
if ((*test_addr != test_data) ||
(*(test_addr + offset) != ~test_data))
{
printf("addr/data bus test failed at address: %08X
", test_addr);
printf("test_data: %08X
", test_data);
printf("*test_addr: %08X
", *test_addr);
return (ERR_FAIL);
}
// bump test data for next loop.
test_data++;
}
return (ERR_NO_ERROR);
}
uint32_t verifyPattern (uint32_t in_begin_addr, uint32_t in_num_bytes)
{
uint32_t rtn = ERR_NO_ERROR;
uint32_t offset;
uint32_t *test_addr = (uint32_t *)in_begin_addr;
// write ram under test to all 5's.
for (offset = 0; offset < in_num_bytes; offset += sizeof(uint32_t))
{
*test_addr++ = 0x55555555;
}
// verify ram under test is 5's.
test_addr = (uint32_t *)in_begin_addr ;
for (offset = 0; offset < in_num_bytes; offset += sizeof(uint32_t))
{
if (*test_addr++ != 0x55555555)
{
printf("data pattern (5) test failed at address: %08X
", test_addr);
rtn = ERR_FAIL;
}
}
// write ram under test to all A's.
test_addr = (uint32_t *)in_begin_addr ;
for (offset = 0; offset < in_num_bytes; offset += sizeof(uint32_t))
{
*test_addr++ = 0xAAAAAAAA;
}
// verify ram under test is A's.
test_addr = (uint32_t *)in_begin_addr;
for (offset = 0; offset < in_num_bytes; offset += sizeof(uint32_t))
{
if (*test_addr++ != 0xAAAAAAAA)
{
printf("data pattern (A) test failed at address: %08X
", test_addr);
rtn = ERR_FAIL;
}
}
return (rtn);
}
test_ram.h
//-----------------------------------------------------------------------------
// file test_ram.h
// rief .
//-----------------------------------------------------------------------------
#include "types.h"
//-----------------------------------------------------------------------------
// Public Function Prototypes
//-----------------------------------------------------------------------------
uint32_t TEST_ram(void);
linker_dsp.cmd
/*****************************************************************************
* linker command file for C6748 test code.
* © Copyright 2009, Logic Product Development Company. All Rights Reserved.
******************************************************************************/
-l rts67plus.lib
//-l ........sllibevmc6748_bsl.lib
-stack 0x00000800
-heap 0x00000800
MEMORY
{
dsp_l2_ram: ORIGIN = 0x11800000 LENGTH = 0x00040000
shared_ram: ORIGIN = 0x80000000 LENGTH = 0x00020000
external_ram: ORIGIN = 0xC0000000 LENGTH = 0x08000000
arm_local_ram: ORIGIN = 0xFFFF0000 LENGTH = 0x00002000
}
SECTIONS
{
.text > shared_ram
.const > shared_ram
.bss > shared_ram
.far > shared_ram
.switch > shared_ram
.stack > shared_ram
.data > shared_ram
.cinit > shared_ram
.sysmem > shared_ram
.cio > shared_ram
}
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮