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.

SYSBIOS not executing clock function if tick period is too low

Other Parts Discussed in Thread: AM3359, SYSBIOS

Hi,

I'm toggling a GPIO pin in my clock function which is configured with a tick period = 1000 us and Period/Initial timeout = 1. I then check the signal on my oscilloscope and see that the signal is indeed toggling every 1000 x 1 us .

Now, I change the tick period to 10 us, and it does not toggle the GPIO pin at that rate. I put a break point in my clock function and notice that it is not even entering that function.

I played around with different values of the tick period and found that if I put a tick period greater than of 65 us, I see the toggling on the oscilloscope. Any value smaller that that, it doesn't enter the clock function.

For my application, I ideally would like to call the clock function every 10 us, which doesn't seem to be working with the clock module. Can anyone point out what's going on and if I'm missing something ?

Thanks !

  • It sounds like a 10usec tick rate is too fast for your application configuration.

    What device is your application running on?  And what is the CPU clock frequency?  

    Clock functions will run in the context of a software interrupt (Swi), which defaults to run at the highest Swi priority level.  Have you reduced the priority of the Clock Swi?  Or do you have other application Swi also configured at the highest Swi priority?  Or, a lot of processing in hardware interrupts (Hwi)?  Any of these situations can load the CPU such that there is not enough time for the Clock Swi to run at a very high rate.  

    Scott

  • Hi Scott, thanks for the reply.

    I'm running my application on the beaglebone with AM3359 processor running at 500 MHz CPU clock frequency. 

    My clock function has the default Swi priority of 15 and I do not have any other Swis or Hwis.  My clock function just toggles a GPIO pin which should be finished well within the 10 us window.

    As I mentioned before, if I look at the execution graph, I can see the Swis posted if the tick period is > 65 us and nothing for values less than that...

    What else do you think it could be ?

    Thanks !

  • OK, thanks.  It seems you should have plenty of CPU cycles!  

    I’ll have to research this… but one other thing that could limit the rate is the input clock frequency for the timer peripheral.  If it is too slow then it will limit the maximum tick rate for the timer and therefore Clock.  Is this possible in your case?

    Thanks,
    Scott

  • Hi Scott, 

    Yes, I think the issue is with the input clock frequency of the dmtimer that I'm using. I'm using the default value which is 32kHz which is too low and I guess that explains the threshold like behavior I notice at 60 us..

    So, I changed the frequency of the timer module to 20 MHz as follows in my .cfg file:

    var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
    Timer.intFreq.hi = 0;
    Timer.intFreq.lo = 20000000;

    Now I get this timer mismatch error when I load my program:

    ti.sysbios.timers.dmtimer.Timer: line 1142: E_freqMismatch: Frequency mismatch: Expected 20000000 Hz, actual: 32765 Hz. You need to modify Timer.intFreq.lo to match the actual frequency.
    xdc.runtime.Error.raise: terminating execution

    By changing the SYS/BIOS cfg script, the expected frequency has changed as indicated by the above error, but the actual frequency still remained at 32 kHz. How do I change that to 20 MHz as well ?

    Thanks


  • You did the right thing to inform SYS/BIOS of the new timer frequency. 

    But one last step is missing, and that is to actually change the clock selection for the DMTIMER within the PRCM module.  SYS/BIOS does not do this automatically as PRCM is often managed/arbitrated by a dedicated system-level clock manager, and depending upon device configuration, the CPU that SYS/BIOS is running on may not have write access permissions for PRCM registers.

    There is a note about SYS/BIOS not doing this deep in the cdoc documentation regarding the dmtimer's frequency check:


    If you change the dmtimer clock selection (via the appropriate CLKSEL_TIMERx_CLK register), then I think the  frequency check will pass, and you’ll get the faster tick capability…

    Scott

  • Thank you Scott ! 

    It's working now. I enabled and changed the timer frequencies of the timers in the GEL file using the link you gave..

    Also, I had to force the clock module to use a timer other than 0, as timer 0 has a maximum frequency of 32kHz. So, I used timer_id = 2.

  • Glad to hear it is working now!  Thanks for reporting back.

    Scott