📄 cnfdsp.c
字号:
/*-------------------------------------------------------------------------*/
/* FILENAME: cnfdsp.c -- DSK Confidence test - DSP Code */
/* */
/* Rev 2.15 17 July 2000 T.J.Dillon - SDRAM update, C6711 update */
/* */
/*-------------------------------------------------------------------------*/
#include <stdio.h>
#include <csl.h>
#include <csl_chip.h>
#include <csl_edma.h>
#include <csl_emif.h>
#include <csl_irq.h>
#include <csl_mcbsp.h>
#include <csl_timer.h>
#include <bsl.h>
#include <bsl_board.h>
#include <bsl_dip.h>
#include <bsl_ad535.h>
#include "cnfDSP.h"
#include "dsk6xHSB.h"
#pragma DATA_SECTION(handShakingBuffer, "my_DataSect")
int handShakingBuffer[HS_BUFFER_LEN];
/*******************************************************************************
* Global variables *
*******************************************************************************/
TIMER_Handle hTimer;
TIMER_Config myTimerConfig = {
0x000003F0, /* CTL register - CPU CLK/4 */
0x00000500, /* PRD register */
0x00000000 /* CNT register */
};
MCBSP_Handle hMcbsp;
AD535_Handle hAD535;
AD535_Config myConfig = { AD535_LOOPBACK_DISABLE,
AD535_MICGAIN_OFF,
AD535_GAIN_0DB,
AD535_GAIN_0DB
};
short sin_table[] = {0, 23170>>2, 32767>>2, 23170>>2,0, -23170>>2, -32767>>2, -23170>>2};
int flag;
//static int exp_chksum,cmp_chksum;
/*-------------------------------------------------------------------------*/
/* main() */
/*-------------------------------------------------------------------------*/
int main()
{
int src,dst,size; /* Used for QDMA */
int error,errortone;
Uint32 io_port_values;
Uint32 pwb_assy_rev;
int ext_mem_size;
/* Initialize the chip support library, required */
CSL_init();
/* Initialize the board support library, required */
BSL_init();
/* dsp and periphiral initialization */
CHIP_RSET(CSR,0x100); /* Disable all interrupts */
CHIP_RSET(IER,1); /* Disable all interrupts except NMI */
CHIP_RSET(ICR,0xffff); /* Clear all pending interrupts */
/*************************************************************************
* Standard 6211 DSK includes 2 MT48LC1M16A1-7 devices =>4MB SDRAM *
* 16Mb (16-bit x 2 banks x 512K) parts = 2MB / part *
* EMIF_SDCTRL=0x07227000 *
* EMIF_SDEXT=0x54529 Board Rev = 1 *
*------------------------------------------------------------------------*
* Standard 6711 DSK includes 2 MT48LC4M16A2-8 devices =>16MB SDRAM *
* 64Mb (16-bit x 4 banks x 1M) parts = 8MB / part *
* EMIF_SDCTRL=0x57116000 *
* EMIF_SDEXT=0x54529 (Hitachi 0x54509) Board Rev = 2 *
*------------------------------------------------------------------------*
* Other 6711 DSK configurations are as follows: *
* 128Mb (16-bit x 4 banks x 2M) parts = 16MB / part (=>32MB SDRAM) *
* EMIF_SDCTRL=0x53116000 *
* EMIF_SDEXT=0x54529 (Hitachi 0x54509) Board Rev = 3 *
* ---------------------------------------------------------------------*
* 256Mb (16-bit x 4 banks x 4M) parts = 32MB / part (=>64MB SDRAM) *
* EMIF_SDCTRL=0x63116000 *
* EMIF_SDEXT=0x54529 Board Rev = 4 *
*************************************************************************/
/******************************************************************************\
* CONFIGURE EMIF *
\******************************************************************************/
EMIF_configArgs(0x00003300, /* EMIF global control register */
0xFFFFFF30, /* CE0 - SDRAM */
0xFFFFFF23, /* CE1 - 32-bit asynch */
0xFFFFFF23, /* CE2 - 32-bit asynch on daughterboard */
0xFFFFFF23, /* CE3 - 32-bit asynch on daughterboard */
0x07117000, /* SDRAM control register (100 MHz) */
0x0000061A, /* SDRAM Timing register */
0x00054519 /* SDRAM Extension register */
);
#if PRINT
printf("\n*TMS320C6211/6711 DSK Confidence Test*\n");
#endif
/*-----------------------------------------------------------------------*/
/* Read DIP switches */
/*-----------------------------------------------------------------------*/
io_port_values = BOARD_readReg(BOARD_REG_IOPORT);
pwb_assy_rev=get_bdrev();
EMIF_RSET(CECTL1,0xFFFFFF03); /* CE1 - 8-bit asynch */
#if PRINT
printf("\n USER_SW3=%d ", DIP_get(DIP_3));
printf(" USER_SW2=%d ", DIP_get(DIP_2));
printf(" USER_SW1=%d ", DIP_get(DIP_1));
printf(" Board Rev=%d\n\n",pwb_assy_rev);
#endif
/*-----------------------------------------------------------------------*/
/* Modify SDRAM parameter value(s) according to board revision */
/*-----------------------------------------------------------------------*/
switch (pwb_assy_rev) {
case 0: EMIF_RSET(SDCTL,0x07126000);
ext_mem_size = EXTERNAL_MEM_SIZE;
break;
case 1: EMIF_RSET(SDCTL,0x07227000);
ext_mem_size = EXTERNAL_MEM_SIZE;
break;
case 2: EMIF_RSET(SDCTL,0x57116000);
ext_mem_size = 4*EXTERNAL_MEM_SIZE;
break;
case 3: EMIF_RSET(SDCTL,0x53116000);
ext_mem_size = 8*EXTERNAL_MEM_SIZE;
break;
case 4: EMIF_RSET(SDCTL,0x63116000);
ext_mem_size = 16*EXTERNAL_MEM_SIZE;
break;
}
/*-----------------------------------------------------------------------*/
/* Perform Hand Shaking */
/*-----------------------------------------------------------------------*/
handShakingBuffer[0] = ID_0;
handShakingBuffer[1] = ID_1;
handShakingBuffer[2] = ID_2;
handShakingBuffer[3] = 0;
handShakingBuffer[4] = 0;
handShakingBuffer[5] = io_port_values;
/*-----------------------------------------------------------------------*/
/* Wait for Host ACK */
/*-----------------------------------------------------------------------*/
while(handShakingBuffer[4] != HOST_RECEIVE_HAND_SHAKING_INFO);
/*-----------------------------------------------------------------------*/
/* Reset handShakingBuffer */
/*-----------------------------------------------------------------------*/
handShakingBuffer[0] = 0;
handShakingBuffer[1] = 0;
handShakingBuffer[2] = 0;
#if PRINT
printf("Hand Shake Complete.\n");
#endif
/*-----------------------------------------------------------------------*/
/* Run DSP forever */
/*-----------------------------------------------------------------------*/
while(1)
{
/*-----------------------------------------------------------------------*/
/* Test for HOST ready */
/*-----------------------------------------------------------------------*/
#if PRINT
printf("\nDSP Ready for HOST Command.\n");
#endif
/*---------------------------------------------------------------------*/
/* Wait until HOST has a command and parameters ready */
/*---------------------------------------------------------------------*/
while(handShakingBuffer[4] != HOST_STATUS_INPUT_READY
&& handShakingBuffer[4] != HOST_STATUS_END_PROCESSING);
/*---------------------------------------------------------------------*/
/* Quit if HOST requests it or Process a HOST command */
/*---------------------------------------------------------------------*/
if(handShakingBuffer[4] == HOST_STATUS_END_PROCESSING)
{
#if PRINT
printf("\nHOST Requested End of Processing.\n");
#endif
break;
}
else
{
handShakingBuffer[4] = DSP_PROCESSING_COMMAND;
}
#if PRINT
printf("\nNew HOST Command Read: ");
#endif
/*---------------------------------------------------------------------*/
/* Process a HOST command */
/*---------------------------------------------------------------------*/
switch(handShakingBuffer[3])
{
/*-------------------------------------------------------------------*/
/* Run the Internal SRAM test and return information if(error) */
/*-------------------------------------------------------------------*/
case ISRAM:
#if PRINT
printf("ISRAM\n");
#endif
/*-----------------------------------------------------------------*/
/* Attempt to write 0x55555555 to numerous locations and read same */
/*-----------------------------------------------------------------*/
#if PRINT
printf(" Write 5's.\n");
#endif
if((error=mem_test(ALL_5,INTERNAL_MEM_START,INTERNAL_MEM_SIZE)) != 0)
{
handShakingBuffer[0]=error;
handShakingBuffer[2]=INTERNAL_MEM_SIZE;
handShakingBuffer[5]=ISRAM_ERR55;
}
else
handShakingBuffer[5]=ISRAM_OK;
/*-----------------------------------------------------------------*/
/* Attempt to write 0xAAAAAAAA to numerous locations and read same */
/*-----------------------------------------------------------------*/
#if PRINT
printf(" Write A's.\n");
#endif
if((error=mem_test(ALL_A,INTERNAL_MEM_START,INTERNAL_MEM_SIZE)) != 0)
{
handShakingBuffer[1]=error;
handShakingBuffer[2]=INTERNAL_MEM_SIZE;
handShakingBuffer[5] |=ISRAM_ERRAA;
}
else
handShakingBuffer[5] |=ISRAM_OK;
break;
/*-------------------------------------------------------------------*/
/* Run the External SDRAM test and return information if(error) */
/*-------------------------------------------------------------------*/
case SDRAM:
#if PRINT
printf("SDRAM\n");
#endif
/*-----------------------------------------------------------------*/
/* Attempt to write 0x5A5A5A5A to numerous locations and read same */
/*-----------------------------------------------------------------*/
#if PRINT
printf(" Write 5A's.\n");
#endif
if((error=mem_test_alt(ALT_5A,EXTERNAL_MEM_START,ext_mem_size)) != 0)
{
handShakingBuffer[0]=error;
handShakingBuffer[2]=ext_mem_size;
handShakingBuffer[5]=SDRAM_ERR5A;
}
else
handShakingBuffer[5]=SDRAM_OK;
/*-----------------------------------------------------------------*/
/* Attempt to write 0xA5A5A5A5 to numerous locations and read same */
/*-----------------------------------------------------------------*/
#if PRINT
printf(" Write A5's.\n");
#endif
if((error=mem_test_alt(ALT_A5,EXTERNAL_MEM_START,ext_mem_size)) != 0)
{
handShakingBuffer[1]=error;
handShakingBuffer[2]=ext_mem_size;
handShakingBuffer[5] |=SDRAM_ERRA5;
}
else
handShakingBuffer[5] |=SDRAM_OK;
break;
/*-------------------------------------------------------------------*/
/* Run the External FLASH test and return information if(error) */
/*-------------------------------------------------------------------*/
case FLASH:
#if PRINT
printf("FLASH\n");
#endif
/*-----------------------------------------------------------------*/
/* Use if FLASH on Factory Board includes Checksum stored in POST */
/*-----------------------------------------------------------------*/
/* This test is turned off because POST changed ... it has no Checksum
#if PRINT
printf(" CHECKSUM");
#endif
if((error=flash_checksum(FLASH_START,POST_SIZE)) != 0)
{
handShakingBuffer[0]=error;
handShakingBuffer[5]=FLASH_ERRCK;
}
else
handShakingBuffer[5]=FLASH_OK;
handShakingBuffer[1]=exp_chksum;
handShakingBuffer[2]=cmp_chksum;
#if PRINT
printf("\n Expected=0x%08x\n Computed=0x%08x\n",exp_chksum,cmp_chksum);
#endif
*/
/*-----------------------------------------------------------------*/
/* Attempt to write 0x55555555 to numerous locations and read same */
/*-----------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -