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.
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.
FreeRTOS Kernel V10.2.1
Harmony Configurator 3.3.01
MPLAB X IDE v5.15
Most of the code here was generated and some abstraction has been removed for simplicity.
static void interrupts_init()
void __ISR(_CORE_TIMER_VECTOR, ipl1AUTO) CORE_TIMER_Handler(void)
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 )
/* unlock system for clock configuration */
SYSKEY = 0x00000000;
SYSKEY = 0xAA996655;
SYSKEY = 0x556699AA;
/* 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;
SYSKEY = 0x33333333;