• AVR Freaks

PIC32MZ - Connecting sys_tick to freeRTOS

Author
Scyvyrn
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2019/06/16 17:55:15
  • Location: 0
  • Status: offline
2019/07/10 18:58:12 (permalink)
0

PIC32MZ - Connecting sys_tick to freeRTOS

I normally do embedded on ARM, so MPLAB and Harmony are very new to me. The earlier project I'm structuring to work with RTOS was done using a much earlier Harmony, but it was decided to use Harmony 3. I couldn't find a way to use Harmony 3 to setup the freeRTOS unlike the older versions, so I set it up myself like I normally would for an ARM project with an abstraction layer. Getting it building cleanly and programming was fairly straightforward.
 
The main_loop() which will be the main task for RTOS, works fine when I just call it directly and it has the LED blinking. The problem seems to be when I try to start RTOS with the vTaskStartScheduler (). It isn't returning, but it isn't running the main_loop() either as the LED isn't blinking. I'm pretty sure the problem is connecting the __ISR(__CORE_TIMER_VECTOR) to the  vPortIncrementTick (), but I can't seem to find an example that uses Harmony 3, and the changes to the initialization seem to be significant from previous versions of Harmony. On ARM I would just add the PortSysTickHandler from the port.c to the VECTOR_SYSTICK, but the auto generated code from Harmony is unfamiliar. I'm also very limited in my de-bugging on this project right now so I'm using the blinking LED to test if the task is running correctly.
 
Even just a basic sample of generated code from Harmony 3 making a freeRTOS project to a PIC32MZ would be helpful now. It seems it has to be something in the plib_evic and the interrupts.c, but it's beating me down right now.
 
Versions:
FreeRTOS Kernel V10.2.1
Harmony Configurator 3.3.01
MPLAB X IDE v5.15
XC32 V2.15
PIC32MZ2048EFM064
 
Most of the code here was generated and some abstraction has been removed for simplicity.
 

static void interrupts_init()
{
    EVIC_SourceStatusClear (INT_SOURCE_CORE_TIMER);
    EVIC_SourceEnable (INT_SOURCE_CORE_TIMER);
}

void __ISR(_CORE_TIMER_VECTOR, ipl1AUTO) CORE_TIMER_Handler(void)
{
    vPortIncrementTic ();
    EVIC_SourceStatusClear (INT_SOURCE_CORE_TIMER);
}

void EVIC_Initialize( void )
{
    INTCONSET = _INTCON_MVEC_MASK;

    /* Set up priority / subpriority of enabled interrupts */
    IPC0SET = 0x4 | 0x0; /* CORE_TIMER: Priority 1 / Subpriority 0 */
}
 
void CLK_Initialize( void )
{

    mplab_disable_interrupts ();

    /* unlock system for clock configuration */
    SYSKEY = 0x00000000;
    SYSKEY = 0xAA996655;
    SYSKEY = 0x556699AA;

    mplab_enable_interrupts ();


    /* Peripheral Module Disable Configuration */
    PMD1 = 0xffffffff;
    PMD2 = 0xffffffff;
    PMD3 = 0xffffffff;
    PMD4 = 0xfffffffe;  /** Final byte from F to E enables TIMER_1*/
    PMD5 = 0xfeffffff;
    PMD6 = 0xfffff0ff;
    PMD7 = 0xffffffef;

    mplab_disable_interrupts ();

    SYSKEY = 0x33333333;

    mplab_enable_interrupts ();
}

 
 
 
 
 
 
#1

2 Replies Related Threads

    Scyvyrn
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2019/06/16 17:55:15
    • Location: 0
    • Status: offline
    Re: PIC32MZ - Connecting sys_tick to freeRTOS 2019/07/16 17:01:34 (permalink)
    0
    I played with the Harmony creation enough to figure things out before this actually posted. What wasn't clear is that freeRTOS is loaded if the core is loaded which was why it wasn't an option.
     
    While Harmony 3 does some things very strangely, the code it generates is far cleaner than what Harmony 2 created. Although I can see why people used to H2 would be dismayed by the changes.
    #2
    LdB_ECM
    Senior Member
    • Total Posts : 125
    • Reward points : 0
    • Joined: 2019/04/16 22:01:25
    • Location: 0
    • Status: offline
    Re: PIC32MZ - Connecting sys_tick to freeRTOS 2019/07/16 19:40:47 (permalink)
    0
    Don't know about harmony but it is easy manually
    Check your project includes port_asm.S  (it is in FreeRTOS\Source\portable\MPLAB\PIC32MZ)
    If you look at the first couple of lines of that you have a thing called configTICK_INTERRUPT_VECTOR it needs to be set to one of the values (whichever timer you are using) in your FreeRTOSConfig.h
     
    That is the connection of the timer to vPortTickInterruptHandler
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5