Hot!Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... ,

Author
Brane2
Junior Member
  • Total Posts : 116
  • Reward points : 0
  • Joined: 2011/09/29 19:56:29
  • Location: Ljubljana, Slovenia
  • Status: offline
2018/05/11 02:01:16 (permalink)
0

Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... ,

I'm trying to set up trivial case of using SYS_TMR for timeouts and paeriodic triggers, but, it doesnt work.
 
I've checked and set upt SYS_TMR in MHC, selected a few instances of TMRs under drivers, selected for SYS_TMR, DRV_TMR0 instance etc.
 
Chasiing the generated code with dbg it looks ok. DRV_TMPs get initialised in system-init.c, after that SYS_TMR is initialised fine, and thing enters normal TASK loop.
I've also checked  status of both times in my app and it looks fine.
 
     var1 = SYS_TMR_Status( sysObj.sysTmr );
    


    var2 = DRV_TMR_Status( sysObj.drvTmr0 );

 
but right after that
  var3 = SYS_TMR_CallbackPeriodic( 500, 1 , flip_led1) ;

 
fails.
 
 
 
 
 
post edited by Brane2 - 2018/05/11 02:04:45
#1

11 Replies Related Threads

    Brane2
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2011/09/29 19:56:29
    • Location: Ljubljana, Slovenia
    • Status: offline
    Re: Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... , 2018/05/11 02:15:01 (permalink)
    0
    Also, it'd be nice to know how to setup the system to be able to step-in those functionswhile debugging.
    When I try to step-in into SYS_TMR_CallbackPeriodic, debugger fails...
     
    #2
    Brane2
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2011/09/29 19:56:29
    • Location: Ljubljana, Slovenia
    • Status: offline
    Re: Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... , 2018/05/11 03:22:46 (permalink)
    0
    One more:
     
    http://microchipdeveloper.com/harmony:tmr-sys
     
    Syggests that SYS_TMR should return BYSY status after successful initialisation.
     
    Plowing through Harmony sources shows that SYS_TMR_CallbackPeriodic is just a wrap around _SYS_TMR_ClientCreate, which
    checks the status of SYS_TMR and fails if it's not READY. ( system/tmr/src/sys_tmr.c in HARMONY ).
     
    Puzzling...
     
     
     
     
     
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 16029
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... , 2018/05/11 09:16:10 (permalink)
    0
    Do you have enough timer instances in the timer pool?
    SYS_TMR_CallbackPeriodic() works OK, the other timer functions work, but are very hard to use.
    The Timers return to the pool on their own.  so you can not be sure if you still own the ID you are checking on.
    #4
    Brane2
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2011/09/29 19:56:29
    • Location: Ljubljana, Slovenia
    • Status: offline
    Re: Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... , 2018/05/11 11:02:04 (permalink)
    0
    Problem doesn't seem to be there.
     
     
    I runt trivial example, which basically just tries to set a blinking LED inside APP_initialize.
    One call to SYS_TMR_CallbackPeriodic. Which  fails.
     
    APP_Tasks is empty, so there is nothing there to "eat" them.
     
    This thing should run on SYS_TMR, which stands on TMR2 through dynamic driver. I have also TMR2 and TMR3 set up on dynamic driver.
     
    Where have I failed ? Or should I perhaps have used TMR2-6 for SYS_TMR service ?
     
     
     
     
     
    #5
    Brane2
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2011/09/29 19:56:29
    • Location: Ljubljana, Slovenia
    • Status: offline
    Re: Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... , 2018/05/11 11:04:40 (permalink)
    0
    NKurzman
    The Timers return to the pool on their own.  so you can not be sure if you still own the ID you are checking on.



     
    What's the point of handle then ?
     
    Also, I didn,t think that would be relevant for SYS_TMR.
     
    SYS_TMR is just one, so no handles...
    #6
    NKurzman
    A Guy on the Net
    • Total Posts : 16029
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... , 2018/05/11 11:47:57 (permalink)
    0
    Not the hardware pool. each call for a Timer service (ie SYS_TMR_CallbackPeriodic()) gets a data struct that holds its state.  There is a "Pool" of these structs defined in the Harmony setup.  Other Harmony drivers (ie TCPIP) use them too.  If there are none left available, then you will get an error.
     
    I said it is hard to use, the handle is useful while it is valid.
    I did not write this.  I assume it is some how useful in the Harmony drivers.
     
    The Call back works as advertised.
    #7
    BillP
    Super Member
    • Total Posts : 262
    • Reward points : 0
    • Joined: 2014/09/28 07:53:35
    • Location: CA
    • Status: offline
    Re: Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... , 2018/05/12 10:33:03 (permalink)
    0
    I think you need to do the call to the periodic timer in the APP_INIT_STATE of the task loop.  I recall trying it in the initialize section and it did not work.  I assume your flip_led1 is the callback code included in the app.c file.
    Also, I agree that the SYS_TMR handle is probably not used in the app code, but it is returned by the SYS_TMR_CallbackPeriodic routine, so use it or not.
    #8
    NKurzman
    A Guy on the Net
    • Total Posts : 16029
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... , 2018/05/12 12:19:20 (permalink)
    0
    I this the thing where you need to call the timer init until it is ready?
    #9
    Brane2
    Junior Member
    • Total Posts : 116
    • Reward points : 0
    • Joined: 2011/09/29 19:56:29
    • Location: Ljubljana, Slovenia
    • Status: offline
    Re: Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... , 2018/05/12 18:26:53 (permalink)
    0
    I've found solution for that. Harmony wants all my timers to have divisor at least 2. And I've set all counters to 32-bit and switched divisors of, so something in its guts gave off.
     
     
     
     
    #10
    Paul PortSol
    Super Member
    • Total Posts : 302
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: 0
    • Status: offline
    Re: Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... , 2018/05/14 06:47:13 (permalink)
    0
    x
    post edited by Paul PortSol - 2018/05/16 04:59:04
    #11
    Paul PortSol
    Super Member
    • Total Posts : 302
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: 0
    • Status: offline
    Re: Harmony SYS_TMR Service, SYS_TMR_CallbackPeriodic fails... , 2018/05/16 05:07:55 (permalink)
    0
    This might help:   TimersPRv01.zip (only zip would upload to this forum, not smaller pdf)
    My MHC settings and code using Harmony System Timers for PIC32MZ and PIC32MX.
     
    For newer code I've found it easier to use a single 1KHz system timer, and take over the rest for my own timeouts etc. using a set of processor independent C functions.
     
    Paul
    #12
    Jump to:
    © 2018 APG vNext Commercial Version 4.5