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.

Data representation in the memory



Hi,

This is my simple code, witch sample by sample transfer audio from I2S module to SDRAM.

 

#pragma DATA_SECTION (RcBuf1,".sdrambuf1")

DATA RcBuf1[16384];

#pragma DATA_SECTION (RcBuf2,".sdrambuf2")

DATA RcBuf2[16384];

#pragma DATA_SECTION (RcBuf3,".sdrambuf3")

DATA RcBuf3[16384];

#pragma DATA_SECTION (RcBuf4,".sdrambuf4")

.....

 

void main( void )

{

    Inti = 0;

    Int16 sample=0;

    Uint16 *address_right;

    Uint16 *address_left;

 

    .......

   // Record Audio function

address_right = (Uint16*)0x28000; // Initialize pointer to first buffer right

address_left  = (Uint16*)0x50000; // Initialize pointer to first buffer left

                    

   for (i=0;i<5;i++)

    

             for ( sample = 0; sample < 16384; sample++,address_right++,address_left++)

             {

                 *address_right = I2S2_W0_MSW_R;

                 *address_left  = I2S2_W1_MSW_R;

                 while((Rcv & I2S2_IR) == 0);   // Wait for receive interrupt to be pending

                  

     address_right += 0x4000; //Address increment

      address_left  += 0x4000; //Address increment           

    

    

}

// Play Audio Function

address_right = (Uint16*)0x28001; // Initialize pointer to first buffer right

address_left  = (Uint16*)0x50001; // Initialize pointer to first buffer left

for (i=0;i<5;i++)

{

             for ( sample = 0; sample < 16384 ; sample++,address_right++,address_left++)

           {

           I2S2_W0_MSW_W = *address_right;

           I2S2_W1_MSW_W = *address_left;

           while((Xmit & I2S2_IR) == 0);  // Wait for interrupt

             }

     address_right += 0x4000; //Address increment

     address_left  += 0x4000; //Address increment           

}

...

 

In general program works fine. Data store and playback sounds nice.

But when I at any time stop program execution and look to memory I see strange situation.

Screenshot of memory window is attached.

All even samples are constant. 

Why it's so? 

 

Thanks!

 

Max

  • Hi,

     

    Can you write any value to even location in the memory to check whether you can write something to it?

    Also can you show me your .cmd linker file?

    Double checking, are you using C5515EVM?

    Regards,

    Hyun

  • Hi Hyun,

     

    Yes, I work with C5515 EVM.

    My .cmd file is

     

    /*-c */

    /*-stack 0x2000 */                  /* PRIMARY STACK SIZE               */

    /*-sysstack 0x2000 */               /* SECONDARY STACK SIZE             */

    /*-heap  0x1000 */                  /* HEAP AREA SIZE  */  

    /*_RTDX_interrupt_mask = ~0x06000010; */

    /* Set entry point to Reset vector                                  */

    /* - Allows Reset ISR to force IVPD/IVPH to point to vector table.  */

    -e reset_isr 

     

    MEMORY

    {

        MMR     (RW) : origin = 0000000h length = 0000c0h /* MMRs */

        DARAM (RW)    : origin = 00000c0h length = 00ff40h  /* on-chip DARAM */

     

       SARAMM  (RW) : origin = 0010000h length = 020000h  /*  4KB */

        SARAM   (RW)  : origin = 0030000h length = 01e000h /* on-chip SARAM */

     

        SAROM_0 (RX)  : origin = 0fe0000h length = 008000h /* on-chip ROM 0 */

        SAROM_1 (RX)  : origin = 0fe8000h length = 008000h /* on-chip ROM 1 */

        SAROM_2 (RX)  : origin = 0ff0000h length = 008000h /* on-chip ROM 2 */

        SAROM_3 (RX)  : origin = 0ff8000h length = 008000h /* on-chip ROM 3 */

     

      SDRAM1  (RWIX): origin = 0x050000, length = 0x010000  /*  64KB */

      SDRAM2  (RWIX): origin = 0x060000, length = 0x010000  /*  64KB */

      SDRAM3  (RWIX): origin = 0x070000, length = 0x010000  /*  64KB */  

      SDRAM4  (RWIX): origin = 0x080000, length = 0x010000  /*  64KB */  

      SDRAM5  (RWIX): origin = 0x090000, length = 0x010000  /*  64KB */      

      SDRAM6  (RWIX): origin = 0x0A0000, length = 0x010000  /*  64KB */

      SDRAM7  (RWIX): origin = 0x0B0000, length = 0x010000  /*  64KB */

      SDRAM8  (RWIX): origin = 0x0C0000, length = 0x010000  /*  64KB */  

      SDRAM9  (RWIX): origin = 0x0D0000, length = 0x010000  /*  64KB */  

      SDRAM10  (RWIX): origin = 0x0E0000, length = 0x010000  /*  64KB */        

      SDRAM  (RWIX): origin = 0x100000, length = 0x6A0000  /* 7.7875 MB */ 

     

    EMIF_CS2 (RW)  : origin = 0800000h  length = 0400000h   /* ASYNC1 : NAND */ 

    EMIF_CS3 (RW)  : origin = 0C00000h  length = 0200000h   /* ASYNC2 : NAND  */

    EMIF_CS4 (RW)  : origin = 0E00000h  length = 0100000h   /* ASYNC3 : NOR */

    EMIF_CS5 (RW)  : origin = 0F00000h  length = 00E0000h   /* ASYNC4 : SRAM */

    }

    SECTIONS

    {

        vectors (NOLOAD)

        .bss        : > DARAM /*, fill = 0 */

        vector      : > DARAM      ALIGN = 256 

        .stack      : > DARAM  

        .sysstack   : > DARAM  

    .sysmem : > DARAM 

        .text       : > SARAM  

        .data       : > DARAM

    .cinit : > DARAM

    .const : > DARAM

    .cio : > DARAM

    .usect   : > DARAM

    .switch     : > DARAM 

       .input    >  SARAMM PAGE 0, align(64)

       .input2 >  SARAMM PAGE 0, align(128)

        .emif_cs2   : > EMIF_CS2

        .emif_cs3   : > EMIF_CS3

        .emif_cs4   : > EMIF_CS4

        .emif_cs5   : > EMIF_CS5

       .sdrambuf1 >  SDRAM1, align(64)  

       .sdrambuf2 >  SDRAM2, align(64)

       .sdrambuf3 >  SDRAM3, align(64)      

       .sdrambuf4 >  SDRAM4, align(64)

       .sdrambuf5 >  SDRAM5, align(64)      

       .sdrambuf6 >  SDRAM6, align(64)  

       .sdrambuf7 >  SDRAM7, align(64)

       .sdrambuf8 >  SDRAM8, align(64)      

       .sdrambuf9 >  SDRAM9, align(64)

       .sdrambuf10 >  SDRAM10, align(64) 

    When I under debug walk through my program I see the following picture.

    Pointer at address 0x28000, value from I2S rx register moves to ALL even addresses.

    Ponter at address 0x28001, value from I2S moves to proper position. 

    Pointer at address 0x28002, value from I2S again moves to ALL even addresses.

    And so on...

    At the end I get right values at odd addresses and last received I2S sample at all even addresses.

    Thanks!
    Max

     

  • I still do have this problem.... :(

     

    Max

  • Hi,

     

    What is DATA type?

    Regards,

    Hyun

  • Hi,

    I found the problem. You used (Unit*16) for beyond 16-bit range address i.e. 0x50000.

     

    When I change to 

        for (i=0;i<5;i++)

      

        for ( j = 0; j < 16384;j++)

        {

       while((Rcv & I2S2_IR) == 0);   // Wait for receive interrupt to be pending

             RcBuf1[j] = j; //I2S2_W0_MSW_R;

             RcBuf2[j] = j; //I2S2_W1_MSW_R;      

          }       

          //address_right += 0x4000; //Address increment

        //address_left  += 0x4000; //Address increment           

      

    You will see all data updated.

    Regards,

    Hyun

  • Hi Huyn.

    Thank you for reply. 

     

    DATA means short. 

     

    Do you have ability to check this code on your hardware?

    Because I get the same results, may be I have problems with same project settings. 

     

    I agree 

    address_right = (Uint16*)0x28000 

    is meaningless operation. 

    I get address_right = 0x8000 and it's out of SDRAM address space.

     

    But, please,  note that in 

    C:\Program Files\Texas Instruments\ccsv4\emulation\boards\evm5515_v1\tests\sdram

    demo project performs the same operation in function memfill16, and it's mistake.

     

    If I assign pointer address like 

    address_right = (Uint32*)0x28000 

    then I write data again only to odd addresses and all even addresses are zero.

    And it's reasonably, because pointer increment is 32bit. 

     

    So, how can I take pointer to sdram address space and have access to all sdram cells? 

    Or this approach is impossible in 16-bit cpu systems?

     

    Thanks!

     

    Max

  • Hi,

     

    I used C5515EVM and checked with a hardware.

    Here is my code:

     

     

    typedef Int16 DATA;

    #pragma DATA_SECTION (RcBuf1,".sdrambuf1")

    DATA RcBuf1[0x10000];

    #pragma DATA_SECTION (RcBuf2,".sdrambuf2")

    DATA RcBuf2[0x10000];

    #pragma DATA_SECTION (RcBuf3,".sdrambuf3")

    DATA RcBuf3[0x10000];

    #pragma DATA_SECTION (RcBuf4,".sdrambuf4")

    DATA RcBuf4[0x10000];

     

     

    Uint32 j;

     

         for ( j = 0; j < 0x10000;j++)

        {

       while((Rcv & I2S2_IR) == 0);   // Wait for receive interrupt to be pending

           RcBuf1[j] = I2S2_W0_MSW_R;

             RcBuf2[j] = I2S2_W1_MSW_R;  

          }               

     

     

      // Play Audio Function

     

         for ( j = 0; j < 0x10000;j++)

         {

             I2S2_W0_MSW_W =  RcBuf1[j];

             I2S2_W1_MSW_W =  RcBuf2[j];

             while((Xmit & I2S2_IR) == 0);  // Wait for interrupt

     

       }

     

     

    Liker:

     

     SDRAM1  (RWIX): origin = 0x050000, length = 0x020000  /*  128KB */

      SDRAM2  (RWIX): origin = 0x070000, length = 0x020000  /*  128KB */

      SDRAM3  (RWIX): origin = 0x090000, length = 0x020000  /*  128KB */  

      SDRAM4  (RWIX): origin = 0x0B0000, length = 0x020000  /*  128KB */  

    Regards,
    Hyun