• AVR Freaks

How to do a simple toggle of a pin outside of main in Harmony

Author
Nmaster88
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2019/06/04 03:30:36
  • Location: 0
  • Status: offline
2019/06/12 07:13:28 (permalink)
0

How to do a simple toggle of a pin outside of main in Harmony

This maybe very basic, but using the Harmony framework outside of the main if i go to another file i can't seem to do something like toggle a pin or do a printf to UART, why? What am i missing?
 
Example: Inside the main.c i do LATGINV = 0x00000001; and it works, now if i go to IntHandlerDrvTmrInstance0 where i want to do the same it does nothing!
 
For these example i started a simple project where i configured the oscillator for a FRC with PLL to work at 32MHz, then in Harmony Framework Configuration -> Drivers -> Timer, i choose a prescale of 256, in the Timer period (i'm not sure) but i want the interrupt to happen at each 8us, so i choose 1.
 
The code in system_interrupt.c i simple put that line:
 
void __ISR(_TIMER_1_VECTOR, ipl1AUTO) IntHandlerDrvTmrInstance0(void)
{
    LATGINV = 0x00000001;
    PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_TIMER_1);
}

 
Maybe a something is missing, but even when i put LATGINV = 0x00000001; elsewhere in code, except main, it doesn't seem to work.
 
Btw i tried to follow whats in this page _https://microchipdeveloper.com/harmony:tmr-static
 
void APP_Initialize ( void )
{
    appData.state = APP_STATE_INIT;
    PLIB_INT_SourceEnable(INT_ID_0, INT_SOURCE_TIMER_1);
}

 
        case APP_STATE_INIT:
        {
            bool appInitialized = true;
       

            if (appInitialized)
            {
                appData.state = APP_STATE_SERVICE_TASKS;
            }
            DRV_TMR0_Start(); // Start the Timers
            break;
        }

 
What i'm using:
PIC32MX470F512L
MPLAB X IDE v5.20
Harmony v2
 
 
post edited by Nmaster88 - 2019/06/12 08:16:41
#1
ric
Super Member
  • Total Posts : 22361
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: How to do a simple toggle of a pin outside of main in Harmony 2019/06/12 07:16:13 (permalink)
0
Plainly that other routine is never getting called.
It's really hard to make any more concrete comment without actually seeing your code.
 
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#2
karan123
Super Member
  • Total Posts : 791
  • Reward points : 0
  • Joined: 2009/02/02 11:11:21
  • Location: 0
  • Status: offline
Re: How to do a simple toggle of a pin outside of main in Harmony 2019/06/12 07:22:53 (permalink)
0
Which Harmony Version and MCU you are using?

Post Code here.
#3
Nmaster88
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2019/06/04 03:30:36
  • Location: 0
  • Status: offline
Re: How to do a simple toggle of a pin outside of main in Harmony 2019/06/12 08:00:26 (permalink)
0
Hi @ric and @karan123 absolutly right, i filled more information about what i used in my initial post.
 
#4
NorthGuy
Super Member
  • Total Posts : 5441
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: How to do a simple toggle of a pin outside of main in Harmony 2019/06/12 08:13:31 (permalink)
0
As ric said, your ISR is never called. Do you have interrupts enabled?
#5
Nmaster88
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2019/06/04 03:30:36
  • Location: 0
  • Status: offline
Re: How to do a simple toggle of a pin outside of main in Harmony 2019/06/12 08:19:01 (permalink)
0
@NorthGuy i think it is. 
 
The implementation of the timer is static, i put a check on Interrupt Mode, but on Alarm Function (don't know if this has something to do with anything) nothing is checked. Am i missing something? What needs to normally be done for it to work?
post edited by Nmaster88 - 2019/06/12 08:20:51
#6
Larry.Standage
Moderator
  • Total Posts : 896
  • Reward points : 0
  • Joined: 2011/12/30 09:50:47
  • Location: 0
  • Status: offline
Re: How to do a simple toggle of a pin outside of main in Harmony 2019/06/12 09:21:31 (permalink)
0
You enable the interrupt source, but not the interrupts in the processor itself. Look at the SYS_INT_Enable(); function to take care of that.
 
Also, make sure you're setting the priority levels correctly. An interrupt with 0 priority won't trigger.
#7
Nmaster88
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2019/06/04 03:30:36
  • Location: 0
  • Status: offline
Re: How to do a simple toggle of a pin outside of main in Harmony 2019/06/12 09:29:43 (permalink)
0
Hi @Larry.Standage In System Services -> Interrupts its checked for Use Interrupt System Service. The Timer i'm using is not the configured throug System Services but in Harmony Framework Configuration -> Drivers -> Timer and the Interrupt Priority is level 1.
 
In sys_int_pic32.c there is not SYS_INT_Disable but a SYS_INT_Disable function.
post edited by Nmaster88 - 2019/06/12 09:31:55
#8
Jump to:
© 2019 APG vNext Commercial Version 4.5