• AVR Freaks

Hot!SYS_TMR_DelayMS issue with Harmony

Author
lio0206
New Member
  • Total Posts : 8
  • Reward points : 0
  • Joined: 2019/10/23 02:47:19
  • Location: 0
  • Status: offline
2020/02/24 03:39:42 (permalink)
0

SYS_TMR_DelayMS issue with Harmony

Hello all
I am trying to use SYS_TMR_DelayMS function with a long time delay like 5 hours
But if I try to set it more than 5 minutes the "timerHandle==SYS_TMR_HANDLE_INVALID" becomes true
did i miss something?
 
/*** TMR Driver Initialization Data ***/
const DRV_TMR_INIT drvTmr0InitData =
{
.moduleInit.sys.powerState = DRV_TMR_POWER_STATE_IDX0,
.tmrId = DRV_TMR_PERIPHERAL_ID_IDX0,
.clockSource = DRV_TMR_CLOCK_SOURCE_IDX0,
.prescale = DRV_TMR_PRESCALE_IDX0,
.mode = DRV_TMR_OPERATION_MODE_16_BIT,
.interruptSource = DRV_TMR_INTERRUPT_SOURCE_IDX0,
.asyncWriteEnable = false,
};
const DRV_TMR_INIT drvTmr1InitData =
{
.moduleInit.sys.powerState = DRV_TMR_POWER_STATE_IDX1,
.tmrId = DRV_TMR_PERIPHERAL_ID_IDX1,
.clockSource = DRV_TMR_CLOCK_SOURCE_IDX1,
.prescale = DRV_TMR_PRESCALE_IDX1,
.mode = DRV_TMR_OPERATION_MODE_IDX1,
.interruptSource = DRV_TMR_INTERRUPT_SOURCE_IDX1,
.asyncWriteEnable = false,
};
 
const SYS_TMR_INIT sysTmrInitData =
{
.moduleInit = {SYS_MODULE_POWER_RUN_FULL},
.drvIndex = DRV_TMR_INDEX_1,
.tmrFreq = 1000,
};
 
I am using harmony 2.05.01
PIC32MX250F256L

Attached Image(s)

#1

6 Replies Related Threads

    BillP
    Super Member
    • Total Posts : 389
    • Reward points : 0
    • Joined: 2014/09/28 07:53:35
    • Location: CA
    • Status: offline
    Re: SYS_TMR_DelayMS issue with Harmony 2020/02/24 08:27:16 (permalink)
    0
    I think you need a 32-bit timer.
    #2
    lio0206
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2019/10/23 02:47:19
    • Location: 0
    • Status: offline
    Re: SYS_TMR_DelayMS issue with Harmony 2020/02/24 18:41:29 (permalink)
    0
    Thanks BillP
     
    I set the drvTmr1InitData
    #define DRV_TMR_OPERATION_MODE_IDX1         DRV_TMR_OPERATION_MODE_32_BIT
     
    So the TMR_1 should use the 32bit timer right?
     
    and set sysTmrInitData
    drvIndex = DRV_TMR_INDEX_1
     
    System timer use the TMR_1?
     
    Did I miss any steps?
    post edited by lio0206 - 2020/02/24 19:19:18
    #3
    BillP
    Super Member
    • Total Posts : 389
    • Reward points : 0
    • Joined: 2014/09/28 07:53:35
    • Location: CA
    • Status: offline
    Re: SYS_TMR_DelayMS issue with Harmony 2020/02/24 18:46:29 (permalink)
    0
    Isn't TMR_1 a 16-bit timer?  I think 2-9 can be configured (in pairs) to be 32-bit timers. 
    #4
    lio0206
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2019/10/23 02:47:19
    • Location: 0
    • Status: offline
    Re: SYS_TMR_DelayMS issue with Harmony 2020/02/24 19:39:50 (permalink)
    0
    Thanks again BillP
    timer driver instances 0
    TMR_ID1 is a 16 bit timer
    timer driver instances 1
    TMR_ID2 is a 32 bit timer
     
    and SYSTEM_TMR_INIT
    select drvIndex = DRV_TMR_INDEX_1
     
    Or am I misunderstanding?
    #5
    NKurzman
    A Guy on the Net
    • Total Posts : 18663
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: SYS_TMR_DelayMS issue with Harmony 2020/02/24 19:45:15 (permalink)
    0
    what Version of Harmony?
     
    That is the System timer service Not a Hardware timer.
    It should take 5 Hours.  Assuming you have done everything right, you will need to single step in to the Harmony code and figure out why it is rejecting you call.
     
    Is the 5 minute call working correctly?
    #6
    lio0206
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2019/10/23 02:47:19
    • Location: 0
    • Status: offline
    Re: SYS_TMR_DelayMS issue with Harmony 2020/02/24 20:09:07 (permalink)
    0
    Thanks NKurzman
     
    I think I found the reason because the SYS_TMR_UNIT_RESOLUTION(Interal Time Units (Hz)) default value is 10000
     
    if(periodMs == 0 || periodMs >= (0xffffffff / SYS_TMR_UNIT_RESOLUTION))
    {
    return false;
    }
    so the maximum of periodMs is  429496Ms->about 7 minutes
    higher delay the will cause "SYS_TMR_HANDLE_INVALID==true"
     
    but in "MPLAB® Harmony Help - System Service Libraries" page 383
     
    "10000 Hz (meaning 0.1 ms units) is the recommended value because the delays than need to be achieved are in the ms range. The service tries to achieve enough resolution for delays in the range of milliseconds. That means that this value cannot be < 1000 and the service will fail to initilize if such a value is attempted. The setting affects the range of delays that can be obtained. delay < (2^32 -1)/SYS_TMR_RESOLUTION gives the maximum delay value, in seconds, that can be achieved For example: delay < 119.3 hours (for SYS_TMR_RESOLUTION == 10000)."
     
    Here is the code I set SYS_TMR_DealyMS
    If I set a delay more than 7 minutes the process go to assert(0); 
    timerHandle=SYS_TMR_DelayMS(10*60000);
    if (timerHandle == SYS_TMR_HANDLE_INVALID)
    assert(0);
    post edited by lio0206 - 2020/02/24 21:18:02
    #7
    Jump to:
    © 2020 APG vNext Commercial Version 4.5