• AVR Freaks

Hot!Harmony 3: how to start Timer2/3 interrupt? [solved]

Author
yts
Super Member
  • Total Posts : 636
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
2019/09/09 23:32:53 (permalink)
0

Harmony 3: how to start Timer2/3 interrupt? [solved]

Environment:
PIC32MX270F256B-50I/SP
core: v3.4.0, csp: v3.4.0

I would like to know the method to start the timer2/3 (32 bits timer) interrupt.

Project Graph is shown in the attached figure.
Three functions (TMR2_Start,TMR2_InterruptEnable, and EVIC_SourceEnable) are used as a test in app.c .

void APP_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    appData.state = APP_STATE_INIT;
TMR2_Start();
TMR2_InterruptEnable();
EVIC_SourceEnable( _TIMER_3_IRQ );
}

However, the interrupt has never occurred, that is , __ISR(_TIMER_3_VECTOR, ipl1AUTO) TIMER_3_Handler (void) function has never been called.

I would be happy if someone helped me.
post edited by yts - 2019/09/12 20:09:01

Attached Image(s)

#1

5 Replies Related Threads

    yts
    Super Member
    • Total Posts : 636
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    Re: Harmony 3: how to start Timer2/3 interrupt 2019/09/12 20:08:00 (permalink)
    0
    I find the solution.

    The check box for TMR3 Clock Enable should be checked manually as shown in the attached figure.
    Only one function, TMR2_Start(), is needed to start tirmer2/3 (32bits).

    void APP_Initialize ( void )
    {
        appData.state = APP_STATE_INIT;
    TMR2_Start();
    }

    Attached Image(s)

    #2
    stbnrivas
    New Member
    • Total Posts : 18
    • Reward points : 0
    • Joined: 2020/01/03 11:43:47
    • Location: 0
    • Status: offline
    Re: Harmony 3: how to start Timer2/3 interrupt? [solved] 2020/09/11 02:53:11 (permalink)
    0

    hello and thanks @yts very helpful your post I would like to reopen this post...

     my environment is:
    - Harmony 3, PIC32mz2048efm144, RTOS
     

    I checked the harmony GUI tool like shown into attached images


    I'm trying to use a interrupt to activate a task who change led and suspend itself again... my code

    void vTaskBlinkKeepAlive(void* pvParams){
        for(;;){
            // an interruption will resume it
            vTaskSuspend(NULL); // self suspend
            GPIO_RH2_Toggle();
        }
    }




    the interesting TMR4 timeout into harmony 3 into `plib_tmr4.c` is

    void TMR4_Initialize(void)
    void TMR4_CallbackRegister( TMR_CALLBACK callback_fn, uintptr_t context )


     
    then I checked that `void TMR4_Initialize(void)` it is using into `initialization.c`

    void SYS_Initialize ( void* data ){
        ...
        TMR4_Initialize();
        ...
    }



    now into my `main.c` I will create a static function as event handler for timer interrupt and join event handler with the callback:

    static void timer4_eventHandler(uint32_t status, uintptr_t context){
        vTaskResume(task_handler_blink_keep_alive);
    }

    int main ( void )
    {
        /* Initialize all modules */
        SYS_Initialize ( NULL );
        ...
        TMR4_CallbackRegister( timer4_eventHandler, NULL );
        TMR4_Start();

        while ( true ){
           xTaskCreate((TaskFunction_t) vTaskBlinkKeepAlive,
                        "pic32-keep-alive",
                        128,
                        NULL,
                        1,
                        &task_handler_blink_keep_alive);
        }
    }


     


    And my problem is that PIC32 restart and restart



    post edited by stbnrivas - 2020/09/11 03:00:02

    Attached Image(s)

    #3
    stbnrivas
    New Member
    • Total Posts : 18
    • Reward points : 0
    • Joined: 2020/01/03 11:43:47
    • Location: 0
    • Status: offline
    Re: Harmony 3: how to start Timer2/3 interrupt? [solved] 2020/09/22 01:58:45 (permalink)
    0
    I'm still stuck... now I'm trying use new harmony core package 3.8.1 and the SYS_TIME_TimerCreate which at least don't  but doesn't reset the pic32 execution.
     
    I added two task to blink diferent leds:
    - one with delay and toggle 
    - another with suspend and toggle and timer will resume it
     
    but the timer which has a event handler registered to resume
     
    I created a repo with the code: https://github.com/stbnrivas/pic32-mz-blink-with-delay-and-sys_timer
     
    any help is welcome... thanks in advanced
     
     
    PD: Also I found a FreeRTOS post which said that interrupt crash the system, I am no sure about, it solves changing assembly but it's for PIC32MX ... it is related with my problem?
     
    https://forums.freertos.o...pt-crashes-system/8818
    #4
    KevinHuang
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2019/08/29 08:13:33
    • Location: 0
    • Status: offline
    Re: Harmony 3: how to start Timer2/3 interrupt? [solved] 2020/09/22 11:55:21 (permalink)
    0
    Try to use other timers.
    I believe that any timer lower than timer4 are used by the harmony(software system clocks).
    If me, I recommend to use the timer timer4, timer5, timer6 .... and so on.
    #5
    BillP
    Super Member
    • Total Posts : 427
    • Reward points : 0
    • Joined: 2014/09/28 07:53:35
    • Location: CA
    • Status: offline
    Re: Harmony 3: how to start Timer2/3 interrupt? [solved] 2020/09/23 16:47:36 (permalink)
    4 (1)
    @stbnrivas - you are making this too hard.

    FreeRTOS has its own timer that controls the frequency of the tasks.  So to blink the LED, you do not need an external timer, callbacks, etc.  Just configure FreeRTOS for a timer interrupt @ 1 msec (I think that is the default).  Then your vTaskBlinkKeepAlive() task should call vTaskDelay(1000) for a 1 second blink. 

    New book: Learn Harmony v3.  Go to amazon.com/books, then search for Bill Petrick
    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5