📄 cnfdsp.c
字号:
/*-------------------------------------------------------------------------*/
/* FILENAME: cnfdsp.c -- DSK Confidence test - DSP Code */
/* */
/* Rev 2.17 21 Sep 2000 Z.Zhang, T.J.Dillon */
/* */
/*-------------------------------------------------------------------------*/
/* HISTORY */
/* Rev 1.00 Created by Z.Zhang */
/* Rev 1.10 Mods a) LEDS and CODEC parameter passing */
/* b) Removed FLASH checksum */
/* Rev 1.20 Mods - Reorganized to be consistent with cnfDSP.c */
/* Rev 1.30 Mods - Added board revision info */
/* Rev 2.00 Mods - Updated for C6711 DSK */
/* Rev 2.10 Mods - Updated for Larger SDRAMs */
/* Rev 2.16 Mods - Added newer memory test for SDRAM */
/* Rev 2.17 Mods - Added -j option to turn off codec test (JP1 Installed)*/
/* */
/*-------------------------------------------------------------------------*/
#include <stdio.h>
#include <c6x.h>
#include "c6211dsk.h"
#include "cnfDSP.h"
#include "dsk6xHSB.h"
#pragma DATA_SECTION(handShakingBuffer, "my_DataSect")
int handShakingBuffer[HS_BUFFER_LEN];
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;
unsigned int io_port_values;
unsigned int user_dip_settings;
unsigned int pwb_assy_rev;
int ext_mem_size;
/* dsp and peripheral initialization */
CSR=0x100; /* disable all interrupts */
IER=1; /* disable all interrupts except NMI */
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 *
*************************************************************************/
*(unsigned volatile int *)EMIF_GCR = 0x3300; /* EMIF global control */
*(unsigned volatile int *)EMIF_CE0 = 0x30; /* EMIF CE0control */
*(unsigned volatile int *)EMIF_CE1 = 0xffffff03; /* EMIF CE1 control, 8bit async */
*(unsigned volatile int *)EMIF_SDCTRL = 0x07227000; /* EMIF SDRAM control */
*(unsigned volatile int *)EMIF_SDRP = 0x61a; /* EMIF SDRM refresh period */
*(unsigned volatile int *)EMIF_SDEXT = 0x54529; /* EMIF SDRAM extension */
#if PRINT
printf("\n*TMS320C6211/6711 DSK Confidence Test*\n");
#endif
/*-----------------------------------------------------------------------*/
/* Read DIP switches */
/*-----------------------------------------------------------------------*/
*(unsigned volatile int *)EMIF_CE1 = CE1_32;// EMIF CE1 control, 32bit async
io_port_values=get_ioport();
user_dip_settings=io_port_values&0x7000000;
pwb_assy_rev=get_bdrev();
*(unsigned volatile int *)EMIF_CE1 = CE1_8;// EMIF CE1 control, 8bit async
#if PRINT
printf("\n USER_SW3=%d ",(user_dip_settings&0x4000000)>>26);
printf(" USER_SW2=%d ",(user_dip_settings&0x2000000)>>25);
printf(" USER_SW1=%d ",(user_dip_settings&0x1000000)>>24);
printf(" Board Rev=%d\n\n",pwb_assy_rev);
#endif
/*-----------------------------------------------------------------------*/
/* Modify SDRAM parameter value(s) according to board revision */
/*-----------------------------------------------------------------------*/
if(pwb_assy_rev ==1)
{
*(unsigned volatile int *)EMIF_SDCTRL = 0x07227000;
ext_mem_size=EXTERNAL_MEM_SIZE;
}
else if(pwb_assy_rev ==2)
{
*(unsigned volatile int *)EMIF_SDCTRL = 0x57116000;
ext_mem_size=4*EXTERNAL_MEM_SIZE;
}
else if(pwb_assy_rev ==3)
{
*(unsigned volatile int *)EMIF_SDCTRL = 0x53116000;
ext_mem_size=8*EXTERNAL_MEM_SIZE;
}
else if(pwb_assy_rev ==4)
{
*(unsigned volatile int *)EMIF_SDCTRL = 0x63116000;
ext_mem_size=16*EXTERNAL_MEM_SIZE;
}
else /* if(pwb_assy_rev ==0) */
{
*(unsigned volatile int *)EMIF_SDCTRL = 0x07126000;
ext_mem_size=EXTERNAL_MEM_SIZE;
}
/*-----------------------------------------------------------------------*/
/* 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 */
/*-----------------------------------------------------------------*/
#if PRINT
printf(" Write 5's.\n");
#endif
if((error=flash_test(0x55,POST_END,FLASH_WRITE_SIZE)) != 0)
{
handShakingBuffer[0]=error;
/* handShakingBuffer[5] |=FLASH_ERR55; Use When Checksum first */
handShakingBuffer[5]=FLASH_ERR55;
}
else
/* handShakingBuffer[5] |=FLASH_OK; Use When Checksum first */
handShakingBuffer[5]=FLASH_OK;
/*-----------------------------------------------------------------*/
/* Attempt to write 0xAAAAAAAA to numerous locations and read same */
/*-----------------------------------------------------------------*/
#if PRINT
printf(" Write A's.\n");
#endif
if((error=flash_test(0xAA,POST_END,FLASH_WRITE_SIZE)) != 0)
{
handShakingBuffer[0]=error;
handShakingBuffer[5] |=FLASH_ERRAA;
}
else
handShakingBuffer[5] |=FLASH_OK;
/*-----------------------------------------------------------------*/
/* Example of Status word of hSB - Used when FLASH test turned off */
/*-----------------------------------------------------------------*/
// handShakingBuffer[5]=TEST_DISABLED;
break;
/*-------------------------------------------------------------------*/
/* Run the MCBSP test and return information if(error) */
/*-------------------------------------------------------------------*/
case MCBSP:
#if PRINT
printf("MCBSP\n");
#endif
#if PRINT
printf(" Digital Loopback Mode.\n");
#endif
if((error=mcbsp0_test()) != 0)
{
handShakingBuffer[0]=error;
handShakingBuffer[5]=MCBSP_ERROR;
}
else
handShakingBuffer[5]=MCBSP_OK;
break;
/*-------------------------------------------------------------------*/
/* Run the TIMER test and return status */
/*-------------------------------------------------------------------*/
case TIMER:
#if PRINT
printf("TIMER\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -