This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28377S: Bugs in external SRAM test in emif1_16bit_asram example

Part Number: TMS320F28377S
Other Parts Discussed in Thread: C2000WARE

I found a few bugs in the external SRAM tests in emif1_16bit_asram.c for F28377S in C2000Ware 1.00.00.00:

1 - Loop variable in mem_read_write() limits external SRAM to 64K x 32 bits

mem_read_write(Uint32 start_addr, Uint32 mem_size)
{
    unsigned long mem_rds;
    unsigned long mem_wds;
    long *XMEM_ps;
    //unsigned int i;    << Change to unsigned long to support external SRAM larger than 64K x 32 bits
unsigned long i;

2 - mem_data_walk only covers half of the memory covered by the other tests for a given mem_size

mem_data_walk(Uint32 start_addr, Uint32 mem_size)
{
    unsigned long sram_rd;
    unsigned long sram_wd;
    unsigned long i;
    int k;
    int m;
    unsigned long  *XM_p;
    unsigned long  *XMEM_p;

    XM_p = (unsigned long *)start_addr;
    //for (i=0; i < mem_size; i=i+64)   << need to double the mem_size to cover the same memory as the other tests because each location is tested normal and inverted
for (i=0; i < (mem_size * 2); i=i+64)

3 - Loop variable in mem_addr_walk() limits external SRAM to 64K x 32 bits

mem_addr_walk(Uint32 start_addr, Uint32 addr_size)
{
    unsigned long sram_rd;
    unsigned long sram_wd;
    //unsigned int k;  << Change to unsigned long to support external SRAM larger than 64K x 32 bits
unsigned long k;
unsigned long xshift; unsigned long *XM_p; unsigned long *XMEM_p;

The remaining are not bugs per se but useful clarifications: 

4 - mem_size is the number of 32 bit words (half of the addressable size given that each address points to 16 bits)

Suggest adding a comment similar to below

#define TEST_PASS            0xABCDABCD
#define TEST_FAIL            0xDEADDEAD
#define ASRAM_CS2_START_ADDR 0x100000
#define ASRAM_CS2_SIZE       0x8000                // number of 32-bit words to test

5 - Remove unused timing values (these do nothing in the code and could be confusing)

#define EMIF1                0
#define EMIF2                1
#define MEM_D_WIDTH          1            // 16Bit Memory Interface
#define TURN_AROUND_TIME     0            // Turn Around time of 2 Emif Clock
#define RD_SETUP_TIME        0            // Read Setup time of 1 Emif Clock
#define RD_STROBE_TIME       3            // Read Strobe time of 4 Emif Clock
#define RD_HOLD_TIME         0            // Read Hold time of 1 Emif Clock
#define WR_SETUP_TIME        0            // Write Hold time of 1 Emif Clock
#define WR_STROBE_TIME       0            // Write Setup time of 1 Emif Clock
#define WR_HOLD_TIME         0            // Write Hold time of 1 Emif Clock
#define EXTEND_WAIT          0            // Disable Extended Wait
#define STROBE_SEL           0            // Disable Strobe Mode.
#define WAIT_POLAR_INV       0
#define WAIT_COUNT           0

Thanks,
Steve