您好,欢迎来到61ic! | [登录] [注册] 忘记密码 | 设为首页 帮助
 . 网站首页 . 业界新闻 . 设计中心 . 移动技术 . TI专栏 . ADI专栏 . FPGA专栏 . 代码工厂 . 官方商城 . 
 . 活动专区 . 新品快递 . 解决方案 . 前沿科技 . TI资源 . ADI资源 . FPGA资源 . 下载中心 . 产品展示 . 
加入收藏
付款方式
联系我们
您现在的位置: 61IC电子在线 >> TI专栏 >> TI C6000 >> TMS320C674x DSP >> 正文
  DSP6748 DDR2的测试程序           ★★★ 【字体:
DSP6748 DDR2的测试程序
作者:forest_w…    文章来源:forest_world    点击数:    更新时间:2014-10-17    


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

}

文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章: 没有了
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    TI C6478 的UART 使用例程,…
    evmc6748_bootloader研究
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:61 湘ICP备13001086号-2