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.

Self loop while freeing the memory

Other Parts Discussed in Thread: TMS320C5515

Hi,

           I am using BUF_alloc to allocate the memory. I have created  4 --  8Bytes buffer,  2-- 16bytes buffer, 4 -- 32bytes buffer, 2-- 128bytes buffer, 2-- 260bytes buffer. Once the memory gets allocated of different size, when tried to free the memory using BUF_free and passing the ptr, and checking the following condition using if statement, the control enters FXN_F_selfloop and never comes out of first if statement.

     if( (BUF_free( &BUF_8B, ptr ) ) )

    {

    }

    else if( BUF_free( &BUF_16B , ptr) )

    {

     

    }

    else if( BUF_free(&BUF_32B , ptr) )

    {

    }

    else if( BUF_free(&BUF_128B , ptr) )

    {

       

    }

    else if( BUF_free(&BUF_256B , ptr) )

    {

    }

         But the memory gets freed when I tried to test only allocating and freeing the memory by creating a new project. i.e I created the same buffers as above mentioned, and first allocated 8bytes of buffer and caught the returned pointer as buf1, second I allocated 4bytes of buffer and caught the pointer as buf2, and later for freeing the memory I passed buf2 pointer first then buf1. The memory got freed successfully.

        When many modules are integrated together, the above condition fails. Can someone please help me out with this?

 

Regards,

Taranum

 

  • Taranum,

    What are you doing within the "if" clause?  I mean, it appears that the first BUF_free is successful correct?

    In what sort of thread are you calling this function?

    Judah

  • Hi Judahvang,

           I am allocating the memory chunks based on the size (in bytes) received, as shown below. So When I want to free the memory I just call free_mem function and pass the pointer which I got while allocating the memory using BUF_alloc. And  while freeing the memory, check to which buffer the pointer belongs to and free that particular block by using BUF_free.

    void *sdk_allocate_memory (UINT32 size)
    {
        Ptr *buf = NULL;

      /*
         * Try allocating from created pools of memory
         * depending on the size given
         */
        
        if (size <= MEM_SIZE_8)

       {
            buf = BUF_alloc(&BUF_8B);
        }

        if ((NULL == buf) && (size <= MEM_SIZE_16))

       {
              buf = BUF_alloc(&BUF_16B);
        }
      
        if ((NULL == buf) && (size <= MEM_SIZE_32))

        {
            buf =  BUF_alloc(&BUF_32B);
        }

        if ((NULL == buf) && (size <= MEM_SIZE_128))

       {     
            buf =  BUF_alloc(&BUF_128B);
        }

        if ((NULL == buf) && (size <= MEM_SIZE_260))

       {
            buf =  BUF_alloc(&BUF_256B);
        }
        
        return buf;
    }

    Regards,

    Taranum

              

  • Taranum,

    A couple of questions:

    (1) Why do you have  Ptr *buf?  Shouldn't it be just   Ptr buf?

    (2) Are you calling this within a TSK?

    (3) Where is the program execution after you call the first BUF_free()?

    Judah

  • Hi Judah,

           1. Yes I have changed  that to void *buf.

           2. Yes this function I am calling within a task.

           3. After calling BUF_free the program execution in under FXN_F_selfloop.

           And I found that the problem is not in MEM_free function. There is an interrupt occurring before calling the mem_free function and that interrupt is not servicing its ISR. Due to which it is entering the self_loop.

    Regards,

    Taranum

  • Judah,

         I am initialising the uart and enabling the uart interrupt before calling mem_free function. When uart interrupt is enabled, its not servicing uart0_isr i.e its service routine. But the same uart module tested individually, its working fine. Can you please guide me over it. And also Before uart_init, the timer interrupt is enabled but even that is not servicing its routine.

    Regards,

    Taranum

  • What version of BIOS are you using?  What device are you running on?

    A Timer should be enabled by default for BIOS.

    Judah

  • Judah,

         I am working on TMS320C5515. The bios version I am using is 5_41_10_36.

    Regards,

    Taranum

  • How are you plugging your ISR functions?

    Judah

  • Judah,

         I was using vector.asm as well as .tcf file earlier, and realised that I had to configure the interrupts using .tcf file. Now I have excluded that file and configured the ISR for UART using HWI_INT6 in the .tcf file. The control is now goin to the specified ISR. I have enabled the HWI_dispatcher.

    1. Can you please tell me how exactly the dispatcher handles entry and exiting of ISR? 

    2. And also can you please tel how do i configure the timer1 using tcf?

     Regards,

    Taranum

  • Hi Taranum --

    Check the DSP/BIOS User's Guide and API Guide for information on the HWI module and how the dispatcher works.

    On the 5515, you can tell the CLK module to use timer 0, 1, or 2.   DSP/BIOS uses the CLK module for an optional system heartbeat.   If you do not call TSK_sleep() or SEM_pend() with a timeout, then you can disable the CLK module.    In this case, you'd manage the shared timer interrupt yourself.

    If you want to use one of the other timers for your own purposes, then you need to program the timer  yourself and register the timer ISR with the CLK module.  The 3 timers share a common interrupt pin and DSP/BIOS will check a status register to determine which timer(s) expired and call the appropriate functions.

    See appendix E of SPRU404P for more information about the CLK module for the 5505.  The same doc applies to 5515.

    On a related note, I think you might want to update to DSP/BIOS 5.41.11 or later.  There was an issue with the timer driver that affected 5525.  I'm not sure if it affected 5515.  But, if you are having problems with the timer, you should probably update to latest 5.41.xy to make sure you are not affected by this.   Install this into default directory and CCS should find it and allow you to use it.

    http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/bios/dspbios/index.html


    Regards,
    -Karl-

    .  

  • Hi Karl,

        I had used the same method to configure the timer1. But When the timer1 INT occurs, the control is not switched to its ISR. I'll surely update the DSP bios version and check the same.

    Regards,

    Taranum

  • Hi Karl,

         I have verified using the new version of BIOS and timer1 works fine. Thank you so much.

    Regards,

    Taranum

  • Hi karl,

          I am using .TCF file to configure the UART INTERRUPT i.e HWI_INT6. The uart_isr is called within a task. When the code is run, the processor halts at  HWI_dispatcher after executing the ISR. But again when I click on the run button the control goes further. Can you please guide me what the problem might be?

        And when autoflow control is enabled during UART_intialization the ISR is executed only once and when autoflow control is disabled the ISR is executed based on the number of bytes we transfer.

         Also stack overflow has occurred ( monitored using ROV -> KNL) at the second time when the control comes to ISR. Can you please tell me how to overcome the stack overflow in TMS320c5515 EVM?

    Regards,

    Taranum