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.

Tiva C series delay problem

Hi ,

I am Also facing one problem with the Tiva controller.   My application takes around  130 KB code size and Ram size 27KB.  I am facing issues regarding the delay. When I am using the same delay functions in another code where the code size is around 30kB and ram size is 5KB the program works very fast whereas for above things it works slow. 

 That I want to say the delay is not constant it is changing according to code size. Please provide some solutions as my application is to be dispatched in few days. I am working on CCS . I guess there might be a problem with the compiler .

Regards

Dhanush

  • Hello Dhanush,

    The delay function has got nothing to do with code size, if it is SysCtlDelay you are using. It is related only to the System Clock Frequency.

    As the code size becomes larger, it would mean hat there is more processing your code would be doing for both peripherals and computation operations. That would mean CPU going to interrupts more often causing your delay loops to be put on hold

    This is an assumption that you have a lot many interrupts as there is no code that I can see.

    Regards

    Amit

    Regards

    Amit

  • Dhanush Nair said:
    When I am using the same delay functions in another code where the code size is around 30kB and ram size is 5KB the program works very fast whereas for above things it works slow.

    How are the delay functions implemented?

    If you are using SysCtlDelay() see Inconsistent delay with SysCtlDelay() compared to ROM_SysCtlDelay() for a possible reason for delays taking longer than expected.

  • Note too that ARM based MCUs have abundance of Timers - which do not suffer any such, "back of the bus" treatment as does humble, "SysCtlDelay()."  Thus - as stated so many times here - "Timers" provide the classic means to create accurate and highly repeatable delays.

    The fact that you must deliver shortly is not to be used as a "wedge" to shift responsibility away from you/your group.  You alone created/agreed to that delivery date - your "need" is best set - and corrected - by you - at your end...

  • hi Amit,

    Amit Ashara said:
    That would mean CPU going to interrupts more often causing your delay loops to be put on hold

          In my code i am using only 3 interrupts.

         SysTickIntHandler() ->   to increment global counter

         UARTIntHandler() -> to get data (not using currently )

         USB0IntHandler-> usb handler ( for usb keyboard )

    I am using CCS5.4 is there any problem in the setting of CCS so that i am getting different delay....

    In the same code  I also observed that when I press key on keyboard and at that time if controller is not busy USB interrupt comes very fast ( it detect key press and key release very quickly)

    If the controller is busy in doing other stuff at that time if i press any key at that time ,  it detect key press and key release very slow (it take near about 1 sec to detect key and 1 sec to detect release key)

    Thanks,

    Dhanush

  • Hello Dhanush,

    As you mentioned, "it depends on the controller activity" Then clearly this is not something to do with code size. Please note that SysTickIntHandler has a higher priority than the other two interrupt sources.

    The USB has multiple source of interrupt and you may want to check if the CPU is so swarmed by interrupts that the code execution of a key press takes time.

    Lastly, busy is a relative term here. What is the controller busy with?

    Regards

    Amit

  • hi Amit,

    In my code my controller is busy in ADC (conversion takes more time ),RTC,LCD,UART,Rf transmitter,etc

    I noted another thing that as ADC takes more time,after removing ADC read function from my code keyboard works fine.

    In code after particular systick count USB Interrupt gets called continuously.I am using code of USBkeyboard from tiva tm4c129x example,I think this systick makes my controller slow. What should i do to detect key quickly.

    Thanks,

    Dhanush

     

  • Hello Dhanush,

    I would presume that you would need to check how ADC Read is being implemented in the application code you have.

    For the SysTick can you convert the SysTick Timer value to what timing interval it generates. if it is like few ms then would suggest you to scale the same as per the requirement of the application.

    Regards

    Amit

  • Dhanush Nair said:
    is there any problem in the setting of CCS so that i am getting different delay

    If your delay function cannot tolerate tools settings changes, that would indicate a problem with your delay function - not the tool!

    You're not just using a 'for' loop - are you...?!

    Dhanush Nair said:
     Please provide some solutions as my application is to be dispatched in few days

    Hmm... before demanding priority attention on this post, how about responding to those who have already responded to your other posts - but with no acknowledgement from you:

    http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/337314/1207441.aspx#1207441

    http://www.catb.org/esr/faqs/smart-questions.html#urgent

     

  • hi Amit,

    I am using  dk-tm4c129x's  "usb_host_hub" code. After doing some modification for tm4c123, i found that if i add delay of  0.5sec/1sec then this code does not work properly. This code is also giving the same problem what i am facing now.

    After adding delay in "usb_host_hub" code it is giving problem in key detection and in key release.

    Regards,

    Dhanush

  • You can't just go randomly throwing delays into code and expect it to keep working regardless!

    Especially, for example, if you put long (0.5-1s) delays in places where interrupts are disabled...

    You still haven't answered the questions people have asked about how you've implemented your delay, how you're using it, etc, etc...

  • hi Andy Neil,

    I have implemented delay first with SysCtlDelay() ,but it is not working.So now i switched to " for( ; ; ) " loops.

    Andy Neil said:
    You can't just go randomly throwing delays into code and expect it to keep working regardless

    I am putting delay in that code because in my project some other functions like ADC are time consuming.If this code will work with delay then and then only it will work with my code.

    Andy Neil said:
    if you put long (0.5-1s) delays in places where interrupts are disabled...

    I am not disabling interrupt in my code any where.

    Regards,

    Dhanush

  • Dhanush Nair said:

    I have implemented delay first with SysCtlDelay() ,but it is not working.So now i switched to " for( ; ; ) " loops.

    Why would you expect that to make a difference?

     

    Dhanush Nair said:
    I am putting delay in that code because in my project some other functions like ADC are time consuming.If this code will work with delay then and then only it will work with my code.

    Which raises several questions.  The first of which is what percentage of the micro's processing time is taken up by these "other functions"?

     I don't know the structure of the code you are modifying but if this is in a loop expected to service the USB I'd be surprised if arbitrary delays did not break it since there is no indication you are using any kind of RTOS/RTK.

    Robert

  • 3125.usb_host_keyboard1.rarhi all,

    I am putting small delay in my code because this delay is similar to other controller work(logically).

    As my keyboard is working with USB interrupt, there should not be matter of delay problem ( i am using TK-tm4c129x's USB HOST code as it is with little modification).

    I observed that when controller is doing other work like ADC read write, at that time if USB interrupt comes it comes very slow after 1sec and key release interrupt also comes very slow after 1 or 1.5 sec.

    Previously i was working on stallaries's lm3s5951 and i never faced this problem in stallaris USB library.

    If any one has still daught i am sending my code.(check this code by commenting   SysCtlDelay(SysCtlClockGet()/30) and removing comment )

    Regards

    Dhanush

  • hi all,

    Have you seen my code.

    Is this the bug in USB library or in TIVA controller.

    Regards,

    Dhanush