⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teb_diag.c

📁 dsp6416开发的底层驱动
💻 C
字号:
/*H******************************************************************************* $Archive::                                                                   $* $Revision::                                                                  $* $Date::                                                                      $* $Author::                                                                    $** DESCRIPTION:  TMS320C64xx TEB test code ** GLOBALS ** PUBLIC FUNCTIONS:*                              * PRIVATE FUNCTIONS:** USAGE/LIMITATIONS:** NOTES: Assumptions:*             TMS320C64x TEB*             CPLD connected to EMIF B, TBCE0*             AMD29LV400BT flash connected to EMIF B, TBCE1*             SDRAM connected to EMIF A, TACE0** COMPILE SWITCHES:**   amd29lv400bt.c*      - Define FLASH_DEBUG to enable debug code for flash.*      - Define SUBROUTINE_IF to enable external call to flash test.***H***************************************************************************/#define teb_diag_c/*---- compilation control switches ----------------------------------------*//****************************************************************************** INCLUDE FILES*****************************************************************************//*---- system and platform files -------------------------------------------*/#include <stdlib.h>#include <stdio.h>#include <c6x.h>/*---- program files -------------------------------------------------------*/#include "c6416teb.h"#include "cpld.h"#include "flash.h"#include "sdram.h"#include "timer.h"#include "emif.h"#include "codec.h"/****************************************************************************** EXTERNAL REFERENCE    *****************************************************************************//*---- data declarations ---------------------------------------------------*/#define  LED_TEST_START   0#define  LED_CPLD         1#define  LED_IRAM         2#define  LED_SDRAM        3#define  LED_FLASH        4#define  LED_CODEC        5#define  LED_PROG_BOOT    8#define  TEST_TIMER_DELAY 300        // Delay between tests#define  BLINK_DELAY      100        // Delay between blink#define  BLINK_COUNT  3              // Blink LED N times for visual/*---- function prototypes -------------------------------------------------*//****************************************************************************** PUBLIC DECLARATIONS *****************************************************************************//*---- data declarations ---------------------------------------------------*//****************************************************************************** PRIVATE DECLARATIONS  *****************************************************************************//*---- context -------------------------------------------------------------*//*---- data declarations ---------------------------------------------------*/	/*---- function prototypes -------------------------------------------------*/extern int SubRoutineFlashTestMain( void );/*---- macros --------------------------------------------------------------*//****************************************************************************** PUBLIC FUNCTION DEFINITIONS*****************************************************************************/SetLedCode ( int Led ){	CPLD_LedOff( LED_ALL );	CPLD_LedOn( Led );   	TIMER_DelayMsec( TEST_TIMER_DELAY );}/******************************************************************************** FUNCTION : mem_test  (Taken from C6711 DSK )** ARGUMENTS :*   INT pattern           <-- Pattern to be written or read from the memory*   INT start_address     <-- Address from which to start testing memory*   INT size_in_word      <-- Number of words to test in memory** DESCRIPTION :*   Write the pattern to memory beginning at the start_address through the*   number of locations specified by size_in_word. Read the same locations*   and generate an error if the value read back differs from the pattern*   written.** OUTPUTS :*   INT error             <-- True if value read differs from pattern written********************************************************************************/int mem_test (int pattern, int start_address, int size_in_word ){  int i;  int error = 0;  int *mem_ptr = (int *)start_address;  /* Write pattern to the memory */  for(i=0;i<size_in_word;i++)  {    *mem_ptr++ = pattern;  }  /* Read memory and compare contents to the pattern written */  mem_ptr = (int *)start_address;  for(i=0;i<size_in_word;i++)  {    if ( *mem_ptr++ != pattern) error++;  }  return error;}/******************************************************************************** FUNCTION : mem_test_alt (Taken from C6711 DSK )** ARGUMENTS :*   INT pattern           <-- Pattern to be written or read from the memory*   INT start_address     <-- Address from which to start testing memory*   INT size_in_word      <-- Number of words to test in memory** DESCRIPTION :*   Write the pattern to odd memory locations beginning at the start_address *   through the number of locations specified by size_in_word.  AND Write the*   complement of the pattern to even memory locations. Read the same locations*   and generate an error if the value read back differs from the pattern*   written.** OUTPUTS :*   INT error             <-- True if value read differs from pattern written********************************************************************************/int mem_test_alt (int pattern, int start_address, int size_in_word ){  int i;  int temp_read, temp_expected;  int error = 0;  int *mem_ptr = (int *)start_address;  /* Write pattern to the memory */  for(i=0;i<size_in_word;i++)  {	if(i%2)	  *mem_ptr++ = ~pattern;	else	  *mem_ptr++ = pattern;  }  /* Read memory and compare contents to the pattern written */  mem_ptr = (int *)start_address;  for(i=0;i<size_in_word;i++)  {	temp_read = *mem_ptr++;	if(i%2)	  temp_expected = ~pattern;	else	  temp_expected = pattern;    if ( temp_read != temp_expected ) error++;  }  return error;}/*F**************************************************************************** NAME:   main** DESCRIPTION:          *       * NOTES:*   *F***************************************************************************/void main( void ){       BOARD_VERSION BrdVer;    int           Led;    int           i;	CSL_init();		/* DSP initialization */	IRQ_globalDisable();	for(i=0;i<32;i++){	IRQ_disable(i);                    /* Disable and clear all IRQ events    */	IRQ_clear(i);                      /* except reset and NMI interrupts     */	}    EMIF_Init();    TIMER_Init();        CPLD_Version( &BrdVer );    printf("Board Version %d\n",BrdVer.BoardVersion );    printf("CPLD Version %d\n",BrdVer.FpgaVersion );        // Very simple Led test.  Turn them all off then on    // one at a time, then off one at a time.    Led = CPLD_LedOff( LED_ALL );    printf("Led reg %0X\n", Led );    for( i=0; i<LED_AVAILABLE; i++ )    {    	Led = CPLD_LedOn( LED_0 << i );    	printf("Led reg ON  %0X\n", Led );    	TIMER_DelayMsec( 100 );    }        for( i=0; i<LED_AVAILABLE; i++ )    {    	Led = CPLD_LedOff( LED_0 << i );    	printf("Led reg OFF %0X\n", Led );    }        CPLD_LedOff( LED_ALL );        // TEST INTERNAL SRAM    SetLedCode ( LED_IRAM );    printf("#### TEST INTERNAL SRAM ####\n");    if(    (mem_test(ALL_5,INTERNAL_MEM_START,INTERNAL_MEM_SIZE))        || (mem_test(ALL_A,INTERNAL_MEM_START,INTERNAL_MEM_SIZE)))    {        printf("Internal SRAM test failed\n");     }     // TEST SDRAM    SetLedCode ( LED_SDRAM );    printf("#### TEST SDRAM ####\n");    if( DRAM_ByteStrobes( SDRAM_TEST_ADDRESS, 0x11223344L ))        printf("SDRAM Byte Strobe test failed\n");            // Test for 0/1 data on bits (31 downto 0 )         if( DRAM_SlidingData32( SDRAM_TEST_ADDRESS, 1,32 ))        printf("SDRAM Sliding Data 1 test failed, 31-0\n");         if( DRAM_SlidingData32( SDRAM_TEST_ADDRESS, 0,32 ))        printf("SDRAM Sliding Data 0 test failed, 31-0\n");             // Test for 0/1 data on bits (63 downto 32 )         if( DRAM_SlidingData32( SDRAM_TEST_ADDRESS+4, 1,32 ))        printf("SDRAM Sliding Data 1 test failed, 63-32\n");         if( DRAM_SlidingData32( SDRAM_TEST_ADDRESS+4, 0,32 ))        printf("SDRAM Sliding Data 0 test failed, 63-32\n");             if( DRAM_SlidingAddr32( SDRAM_TEST_ADDRESS , SDRAM_ADDRESS_BITS))        printf("SDRAM Sliding Address test failed\n");            // Test that all bits in the SDRAM can be written to 0/1    if(    (mem_test(ALL_5,SDRAM_TEST_ADDRESS,(1<<SDRAM_ADDRESS_BITS)))        || (mem_test(ALL_A,SDRAM_TEST_ADDRESS,(1<<SDRAM_ADDRESS_BITS))))        printf("SDRAM 55/AA test failed\n");                       // Bulk test of DRAM data == DRAM address. Tests that each address    // is unique.    if( DRAM_AddressAsData( SDRAM_TEST_ADDRESS, (1<<SDRAM_ADDRESS_BITS) ))        printf("SDRAM Data==Address failed\n");                // TEST FLASH             SetLedCode ( LED_FLASH );           printf("#### TEST FLASH ####\n");              if( SubRoutineFlashTestMain() )        printf("FLASH Test failed\n");    CPLD_LedOff( LED_ALL );        printf("\n$$$$ ALL DONE $$$$\n" );                   } 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -