Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Newbie completely lost

Posted by Grant Brown on October 21, 2008
Hi List,

Device / Port : PIC32

My project is copied below for reference.

It got the PIC32 demo running OK but now I have the following problems.

1) - I tried to slim down the project by deleting all of the demo tasks and demo files from the project and now the compiler fails to compile the project copied below.

2) - When I did have the project compiling but with the demo "Main" function commented out and running my own "Main" function I had the following problems.

My task got created - this was confirmed by checking that the return value was pdPASS

However the scheduler did not start. This was confirmed by RD2 started flashing - see code below.

So my questions are,

(a) - What are the minimal files required to compile a PIC32 project with the RTOS and a minimal task such as the one below.

(b) - With only using the task below why did the scheduler not start ?

Many thanks in advance

kind Regards
Grant Brown

/* Standard includes. */
#include <plib.h>
#include <stdio.h>

/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"

#pragma config POSCMOD = HS, FNOSC = PRIPLL, FPBDIV = DIV_2

static void GrantsTask(void *pvParameters);
static void prvSetupHardware( void );
int Cnt = 0;
int main( void )

// configure the wait states and peripheral bus clock


// configure the port registers
PORTSetPinsDigitalOut(IOPORT_D, BIT_0|BIT_1|BIT_2);
// initialize the port pin states = outputs low

if(xTaskCreate( &GrantsTask, "GKB_Tsk", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ) == pdPASS)
// start the scheduler. */
// Will only reach here if there is insufficient heap available to start the scheduler
if(++Cnt == 65000)
Cnt = 0;

return 0;

static void GrantsTask(void *pvParameters)
portTickType xLastExecutionTime;
const portTickType xFrequency = 500;
//PORTWrite(IOPORT_D, 0x05); // 0000 0000 0000 0101
xLastExecutionTime = xTaskGetTickCount();


static void prvSetupHardware( void )
/* Set the system and peripheral bus speeds and enable the program cache*/
SYSTEMConfigPerformance( configCPU_CLOCK_HZ - 1 );

/* Setup to use the external interrupt controller. */


/* Setup the digital IO for the LED's. */


void vApplicationStackOverflowHook( void )
/* Look at pxCurrentTCB to see which task overflowed its stack. */
for( ;; );

void _general_exception_handler( unsigned portLONG ulCause, unsigned portLONG ulStatus )
/* This overrides the definition provided by the kernel. Other exceptions
should be handled here. */
for( ;; );

RE: Newbie completely lost

Posted by Dave on October 21, 2008
In the first case you dont say why the code would not compile. I cannot offer advice without knowing the error message the compiler gave.

In the second case you have the code:
if(xTaskCreate( &GrantsTask,

remove the &. The first parameter is a pointer to the task function. With the & you are passing in the address of a pointer to the function.

RE: Newbie completely lost

Posted by Grant Brown on October 21, 2008

Sorroy, here are the error messages

Main.c: In function `main':
Main.c:47: error: `configMINIMAL_STACK_SIZE' undeclared (first use in this function)
Main.c:47: error: (Each undeclared identifier is reported only once
Main.c:47: error: for each function it appears in.)
Main.c:47: error: `tskIDLE_PRIORITY' undeclared (first use in this function)
Main.c:47: error: `pdPASS' undeclared (first use in this function)
Main.c: In function `GrantsTask':
Main.c:72: error: `portTickType' undeclared (first use in this function)
Main.c:72: error: syntax error before "xLastExecutionTime"
Main.c:73: error: syntax error before "xFrequency"
Main.c:75: error: `xLastExecutionTime' undeclared (first use in this function)
Main.c:78: error: `xFrequency' undeclared (first use in this function)
Main.c: In function `prvSetupHardware':
Main.c:89: error: `configCPU_CLOCK_HZ' undeclared (first use in this function)
Main.c: At top level:
Main.c:110: error: syntax error before "ulCause"
Main.c:116:64: warning: no newline at end of file
Halting build on first failure as requested.

Kind Regards
Grant Brown

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner