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

📄 edc_example.c

📁 dsp tms320c6486的csl例程
💻 C
字号:
/*  ===========================================================================
 *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005
 *
 *   Use of this software is controlled by the terms and conditions found in 
 *   the license agreement under which this software has been supplied.
 *   ==========================================================================
 */
 
/** ===========================================================================
 *
 *   @file  Edc_example.c
 *
 *   @path  $(CSLPATH)\example\edc\src
 *
 *   @desc  Example of EDC
 *
 *  ============================================================================
 *   @n Target Platform: EVM
 *  ============================================================================
 *   @n <b> Example Description </b>
 *   @n This is an example of the EDC CSL usage. This example do the following
 *      operations.
 *      - Enables the EDC for L1P
 *      - Enables the pages
 *      - Enables the EDC for L2
 *      - Sets up the Interrupt for L1P and L2 errors
 *      - Waits for error generate
 *      - After error generation checks for a error address in which memory  
 *        the error is generated
 *      - Reads L1P and L2 error addresses
 *      - Checks all the L2 and L1P error status
 *      - Clears the generated errors
 *      - Print the result
 *  
 * =============================================================================
 *      
 *   <b> Procedure to run the example </b>
 *   @verbatim
 *      1. Configure the CCS setup to work with the emulator being used
 *      2. Please refer CCS manual for setup configuration and loading 
 *         proper GEL file
 *      3. Launch CCS window
 *      4. Open project Edc_example.pjt
 *      5. Build the project and load the .out file of the project.
 *          
 *   @endverbatim
 *
 */


/* =============================================================================
 *  Revision History
 *  ===============
 *  12-Sept-2005 ds         File Created
 *  14-Feb-2006 ds          Added error generation code function call 
 * ============================================================================
 */
 
#include <csl_edc.h>
#include <csl_intc.h>
#include <edc_examp.h>
#include <csl_intcAux.h>
#include <stdio.h>

/* Intc variable declaration */
CSL_IntcEventHandlerRecord Record[10];

/* Global variable */
Uint32    error_generated = 0;

/* Foraward declarations */
interrupt void edcIsr(void);
void setUpInterrupt (void);
void edc_example (void);

/*
 * =============================================================================
 *   @func   main
 *
 *   @desc
 *     This is the main routine for the file.
 *
 * =============================================================================
 */

void main (void) 
{   
    /* Invoke example */
    edc_example ();
    
    return;
}

/*
 * =============================================================================
 *   @func   edc_example
 *   @desc
 *        This function demonstrates the functionality of EDC.
 *        It implements following steps
 *          1. Enables the EDC for L1P
 *          2. Enables the pages
 *          3. Enables the EDC for L2
 *          4. Sets up the Interrupt for L1P and L2 errors
 *          5. Waits for error generate
 *          6. After error generation checks for a error address in which memory  
 *             the error is generated
 *          7. Reads L1P and L2 error addresses
 *          8. Checks all the L2 and L1P error status
 *          9. Clears the generated errors
 *
 *   @arg    None
 *
 *   @eg
 *      edc_example ();
 *
 * =============================================================================
 */
void edc_example (void)
{
    CSL_Status          status;
    CSL_EdcErrorStatus  errStat;
    CSL_EdcAddrInfo     addrInfo; 
         
    /*Configure the interrupts*/
    setUpInterrupt();
    
    /* Enable the L1P EDC */
    status = CSL_edcEnable(CSL_EDC_L1P);
    if (status != CSL_SOK) {
        printf("EDC enable for L1P is failed\n");
        return;
    }
    else {
        printf("EDC enable for L1P is passed\n");
    }
    
    /* EDC page0 enable */
    status =  CSL_edcPageEnable(0xffffffff,CSL_EDC_UMAP0);
    if (status != CSL_SOK) {
        printf("EDC page0 enable is failed\n");
        return;
    }

    /* EDC page1 enable */
    status = CSL_edcPageEnable(0xffffffff,CSL_EDC_UMAP1);
    if (status != CSL_SOK) {
        printf("EDC page1 enable is failed\n");
        return;
    }
    
    /* Enable the L2 EDC */
    status = CSL_edcEnable(CSL_EDC_L2);
    if (status != CSL_SOK) {
        printf("EDC enable for L2 is failed\n");
        return;
    }
    else {
        printf("EDC enable for L2 is passed\n");
    }
    
    /* This Functions is there as part of the library */
    edc_err_gen_code ();
    
    /* Get interrupt here */
    while (!error_generated);
        
    /* After error generation check for a error address where in which   
     * memory the error is generated 
     */
    /* Read L1P error address */
    CSL_edcGetErrorAddress (CSL_EDC_L1P, &addrInfo);
       
    /* Read L2 error address */
    CSL_edcGetErrorAddress (CSL_EDC_L2, &addrInfo);
       
    /* Get the all L2 error status */
    CSL_edcGetHwStatus (CSL_EDC_L2, CSL_EDC_QUERY_ERRORSTAT, 
                                   &errStat);
       
       
    /* Check for data fetch parity error and clear it */
    if ((errStat & CSL_EDC_DERR) == CSL_EDC_DERR) {
           CSL_edcClear (CSL_EDC_L2, CSL_EDC_DCLR);
    }
    
    /* Check for program fetch parity error and clear it */
    else {
        if ((errStat & CSL_EDC_IERR) == CSL_EDC_IERR) {
            CSL_edcClear (CSL_EDC_L2, CSL_EDC_PCLR);
        }
        /* Check for dma read parity error and clear it */
        else {
            if ((errStat & CSL_EDC_DMAERR) == CSL_EDC_DMAERR) {
                CSL_edcClear (CSL_EDC_L2, CSL_EDC_DMACLR);
            }
        }
    }
       
    /* Get the all L1P error status */
    CSL_edcGetHwStatus (CSL_EDC_L1P, CSL_EDC_QUERY_ERRORSTAT, 
                                  &errStat);
    /* Check for program fetch parity error and clear it */
    if ((errStat & CSL_EDC_IERR) == CSL_EDC_IERR) {
        CSL_edcClear (CSL_EDC_L2, CSL_EDC_PCLR);
    }
    /* Check for dma read parity error and clear it */
    else {
        if ((errStat & CSL_EDC_DMAERR) == CSL_EDC_DMAERR)
        CSL_edcClear (CSL_EDC_L2, CSL_EDC_DMACLR);
    }
    
    printf ("EDC Example Done\n");
}   

/*
 * =============================================================================
 *   @func  edcIsr
 *  
 *   @arg
 *      NONE
 *
 *   @desc
 *      This is the setup interrupt for edc parity check error.
 *
 *   @return
 *      NONE
 *
 * =============================================================================
 */
void setUpInterrupt(void)
{

    CSL_IntcObj intcObjEdc1;
    CSL_IntcObj intcObjEdc2;
    CSL_IntcObj intcObjEdc3;
    
    CSL_IntcHandle hIntcEdc1;
    CSL_IntcHandle hIntcEdc2;
    CSL_IntcHandle hIntcEdc3;
    
    CSL_IntcContext context;
    CSL_IntcParam vectId; 
    
    context.numEvtEntries = 10;
    context.eventhandlerRecord = Record;

    CSL_intcInit(&context);
    /* Global APIs */
    /* Enable NMIs */
    CSL_intcGlobalNmiEnable();
    
    /* Enable Global Interrupts */
    CSL_intcGlobalEnable(NULL);
    CSL_intcGlobalExcepEnable();
    
    /* Opening a handle for the PMC-ED-IDMA */
    vectId = CSL_INTC_VECTID_4;
    hIntcEdc1 = CSL_intcOpen (&intcObjEdc1, CSL_INTC_EVENTID_L1P_ED1, &vectId, 
                              NULL);
    
    
    /* Opening a handle for the UMC-EDC corrected error detect 116*/ 
    vectId = CSL_INTC_VECTID_5;
    hIntcEdc2 = CSL_intcOpen (&intcObjEdc2, CSL_INTC_EVENTID_L2_ED1, &vectId, 
                             NULL);
    
    
    /* Opening a handle for the UMC-EDC uncorrected error detect 117*/ 
    vectId = CSL_INTC_VECTID_6;
    hIntcEdc3 = CSL_intcOpen (&intcObjEdc3, CSL_INTC_EVENTID_L2_ED2, &vectId,
                              NULL);
        
    /* Hook Isr */
    CSL_intcHookIsr(CSL_INTC_VECTID_4,edcIsr);
    
    CSL_intcHookIsr(CSL_INTC_VECTID_5,edcIsr);
    
    CSL_intcHookIsr(CSL_INTC_VECTID_6,edcIsr);
    
    /* Enabling edc   */
    CSL_intcHwControl(hIntcEdc1,CSL_INTC_CMD_EVTENABLE,NULL);   
    CSL_intcHwControl(hIntcEdc2,CSL_INTC_CMD_EVTENABLE,NULL);   
    CSL_intcHwControl(hIntcEdc3,CSL_INTC_CMD_EVTENABLE,NULL);
}

/*
 * =============================================================================
 *   @func  edcIsr
 *  
 *   @arg
 *      NONE
 *
 *   @desc
 *      This is the interrupt service routine for edc parity check errors.
 *
 *   @return
 *      NONE
 *
 * =============================================================================
 */
interrupt void edcIsr(void)
{
    
    error_generated = 1;
}

⌨️ 快捷键说明

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