DSP6748DDR2的测试程序

main_ram.c

//-----------------------------------------------------------------------------

// \file    main.c
// \brief   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
//-----------------------------------------------------------------------------
// \brief   entry point for bsl test code.
// \param   none.
// \return  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("\r\n\r\n");

   if (results != ERR_NO_ERROR)
      printf("\r\n\r\n********** C6748 TEST FAILED **********\r\n\r\n");
   else
      printf("\r\n\r\n********** C6748 TEST PASSED **********\r\n\r\n");

}


test_ram.c

//-----------------------------------------------------------------------------

// \file    test_ram.c

// \brief   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

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

// \brief   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.

//

// \return  uint32_t

//-----------------------------------------------------------------------------

uint32_t TEST_ram(void)

{

   uint32_t rtn = 0;


   printf("------------------------------------------------------------\r\n");

   printf("                     C6748 RAM Test\r\n\r\n");


   printf("Test Description\r\n");

   printf("----------------\r\n");

   printf("this code verifies the mDDR address bus and writes/verifies \r\n");

   printf("data patterns to the mDDR. \r\n");

   printf("------------------------------------------------------------\r\n\r\n");

   //-------------------------------------

   // initialize the required bsl modules.

   //-------------------------------------

   // nothing to init for this test. ram was taken care of in gel or main.

   

   //--------------

   // execute test.

   //--------------

   printf("\r\nExecute Test\r\n");

   printf("------------\r\n\r\n");

   

/*

   printf("--- Test address and data bus ---\r\n");

   rtn = verifyAddrDataBus(DDR_MEM_BASE);

   if (rtn != ERR_NO_ERROR)

   {

      return (rtn);

   }

   else

   {

      printf("\taddress/data bus test passed\r\n\r\n");

   }

*/

   printf("--- Test data pattern ---\r\n");

   rtn = verifyPattern(DDR_MEM_BASE, DDR_MEM_SIZE / 2);

   if (rtn != ERR_NO_ERROR)

   {

      return (rtn);

   }

   else

   {

      printf("\tdata pattern test passed\r\n\r\n");

   }

   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\r\n", test_addr);

         printf("test_data: %08X\r\n", test_data);

printf("*test_addr: %08X\r\n", *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\r\n", 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\r\n", test_addr);

         rtn = ERR_FAIL;

      }

   }

   return (rtn);

}

test_ram.h

//-----------------------------------------------------------------------------

// \file    test_ram.h

// \brief   .

//-----------------------------------------------------------------------------

#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 ..\..\..\..\bsl\lib\evmc6748_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

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值