5 Replies Latest reply on Mar 21, 2013 6:06 PM by perry.neben

    How to use the complete DMA buffer area with CyU3PDmaChannelCreate?

    danilo.tromp

      How to use the complete DMA buffer area?

         

      I like to know how to use the complete DMA buffer area (of where the unallocatable part is going)

         

      When using the default fx3.ld linker script, I can allocate a maximum of 13 x 16Kb Dma buffers with CyU3PDmaChannelCreate, any requests for more buffer will fail.

         

      When reading the fx3.ld and the FX3 Memory Map section of the programmers manual, I come to the conclusion there is 256Kb available for dma buffers. So where is the remaining 3 x 16Kb?

         

      The default memory map used for FX3 applications is as follows:

         

         Descriptor area Base: 0x40000000 Size: 12KB
         Code area       Base: 0x40003000 Size: 180KB   
         Data area       Base: 0x40030000 Size: 32KB    
        
         Driver heap     Base: 0x40038000 Size: 32KB  (0x8000)  (Update cyfxtx.c to change this.)
         Buffer area     Base: 0x40040000 Size: 256KB (0x40000) (Update cyfxtx.c to change this.)
        

         

      I also adapted the fx3.ld and cyFxTx.c to change the allocatable DMA buffer area to 336Kb.
      When I use these settings, I manage to allocate 18*16Kb Dma buffers with CyU3PDmaChannelCreate (in my application this is a buffer of 1.6ms)

         


      I expect to get 21 x 16KByte buffers. So again I am missing 3 x 16Kbyte...

         

      Adapted CyFxtc.c (set USE_CUSTOMLD compile flag to use)
      ----------------
      #ifdef USE_CUSTOMLD
      #define CY_U3P_MEM_HEAP_BASE         ((uint8_t *)0x40024000)   // custom. Must match fx3.ld in current dir
      #else
      #define CY_U3P_MEM_HEAP_BASE         ((uint8_t *)0x40038000)
      #endif

         

      Adapted fx3.ld
      ---------------
         /*
         Descriptor area Base: 0x40000000 Size: 12KB    
         Code area       Base: 0x40003000 Size: Reduced to 116KB (0x1D000)
         Data area       Base: 0x40020000 Size: Reduced to 16KB (0x04000)
        
         Driver heap     Base: 0x40024000 Size: 32KB  (0x8000) (Update cyfxtx.c to change this.)
         Buffer area     Base: 0x4002C000 Size: 336KB (0x54000)  (Update cyfxtx.c to change this.)
         */  
        
         ...
        
       SYS_MEM  : ORIGIN = 0x40003000 LENGTH = 0x1D000  
       DATA  : ORIGIN = 0x40020000 LENGTH = 0x4000  
       
      Any suggestions?

        • 1. Re: How to use the complete DMA buffer area with CyU3PDmaChannelCreate?
          content.librarian

          Hello dtromp_nl,

             

          have you also changed the address ranges in the SECTION area of the *.ld file? You should change the data region as you changed it in the header of the .ld file.

             

          SECTIONS
          {
              . = 0x100;
              .vectors :
              {
                  *(CYU3P_ITCM_SECTION);
              } >I-TCM

              . = 0x40003000; /* SYS_MEM ORIGIN */
              .text :
              {
                  *(.text*)
                  *(.rodata)
                  *(.rodata*)
                  *(.constdata)
                  *(.emb_text)
                  *(.init_array)
                  *(.data*)
                  *(CYU3P_EXCEPTION_VECTORS);
                   _etext = .;
              } > SYS_MEM

            . = ALIGN(4);
           
              .ctors :
              {
                  PROVIDE(__ctors_start__ = .);
                  KEEP(*(SORT(.ctors.*)))
                  KEEP(*(.ctors))
                  PROVIDE(__ctors_end__ = .);
              } >SYS_MEM
             
              .dtors :
              {
                  PROVIDE(__dtors_start__ = .);
                  KEEP(*(SORT(.dtors.*)))
                  KEEP(*(.dtors))
                  PROVIDE(__dtors_end__ = .);
              } >SYS_MEM
           
              . = ALIGN(4);


              . = 0x40020000; /* DATA ORIGIN */
              .data :
              {
                  _data = .;
                  *(.data)
                  * (+RW, +ZI)
                  _edata = .;
              } > DATA
          .

             

          .

             

          .

             

          regards,

             

          lumpi

          • 2. Re: How to use the complete DMA buffer area with CyU3PDmaChannelCreate?
            content.librarian

            Hi I forgot,

               

            it is just a code snippet of a .ld file it must not be the same as yours. You just have to take care, that the beginning of code and data section is the same as you defined at to of the .ld file.

               

            regards,

               

            lumpi

            • 3. Re: How to use the complete DMA buffer area with CyU3PDmaChannelCreate?
              danilo.tromp

              Hi,

                 

              I tried your suggestion. But I am still missing 3x16Kb buffer when I check the return value of

                 

                CyU3PDmaChannelCreate

              • 4. Re: How to use the complete DMA buffer area with CyU3PDmaChannelCreate?
                content.librarian

                Hi,

                   

                I belief that a thread stack and some other stuff of peripherals also allocate in these memory regions. May be you can find some documentation in the FX3 manual memory map.

                   

                regards,

                   

                lumpi

                • 5. Re: How to use the complete DMA buffer area with CyU3PDmaChannelCreate?
                  perry.neben

                  The Memory Map (figure 3-15 in section 3.8 of the FX3 Programmers Manual.pdf) says that the top 16KB of RAM contains the "Translation Table (all sections)" from MAX-16KB to MAX.  I was seeing CY_U3P_ERROR_MEMORY_ERROR when trying to CyU3PDmaChannelCreate() the last 8KB of RAM (MAX-8KB on the 256KB 3011, maybe the reduced RAM size of the 3011 reduces the translation table to 8K?)  The comment in cyfxtx.c seems to imply that you can use all of the memory (to MAX in the memory map), if you aren't using the 2-stage boot loader:

                     

                   

                     

                  /* The last 32 KB of RAM is reserved for 2-stage boot operation. This value can be changed to
                     0x40080000 if 2-stage boot is not used by the application. */
                  #define CY_U3P_SYS_MEM_TOP           (0x40078000)

                     

                   

                     

                  Maybe I'm interpreting this incorrectly, but maybe it should say:

                     

                   

                     

                  /* The last 32 KB of RAM is reserved for 2-stage boot operation and the translation table. This value can be changed to
                     0x4007C000 if 2-stage boot is not used by the application. */
                  #define CY_U3P_SYS_MEM_TOP           (0x40078000)